Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What could cause error on this line
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01526039
Message ID:
01526054
Vues:
62
>>is very very long. Imagine that you have 30 fields. And this expression is created in a data driven approach scanning fields of the dictionary. Here is a segment of this code:
>>
>>
>>cSqlInsert = "insert into " + ALLTRIM(DICT.TBL_NAME) + " "
>>cSqlInsertValues = "" 
>>
>>DO WHILE !EOF() AND DICT.TBL_NAME = cTableName
>>	
>>   cSqlInsert = cSqlInsert + IIF( EMPTY(cSqlInsertValues),"( ",", ") + ALLTRIM(DICT.FLD_NAME) 
>>		
>>   cSqlInsertValues = cSqlInsertValues + IIF( EMPTY(cSqlInsertValues),"( ",", ") +  "?" + ALLTRIM(DICT.TBL_NAME) + "." + ALLTRIM(DICT.FLD_NAME) 
>>	
>>    SKIP IN DICT
>>
>>ENDDO 
>>
>>cSqlInsert = cSqlInsert + ") VALUES " + cSqlInsertValues + ")"
>>
>>
>>So the above code creates this long cSqlInsert. Any suggestions on what to change?
>
>
>That way of creating string variable can be longer that 256 chars :-)
>
>What if:
>
>cSqlInsert        = "insert into " + ALLTRIM(DICT.TBL_NAME) + "("
>cSqlInsertValues = "" 
>SCAN WHILE DICT.TBL_NAME = cTableName
>     cSqlInsert       = cSqlInsert                                      +       ALLTRIM(DICT.FLD_NAME) + ", "
>     cSqlInsertValues = cSqlInsertValues + "?" + ALLTRIM(DICT.TBL_NAME) + "." + ALLTRIM(DICT.FLD_NAME) +", " 
>ENDSCAN
>cSqlInsert = LEFT(cSqlInsert, LEN(cSqlInsert)-2)+ ") VALUES (" + LEFT(cSqlInsertValues, LEN(cSqlInsertValues)-2) + ")"
>
>
>If you have problems, please write the cSqlInsert into text file and attach it here :-)

I am trying to apply your approach and I am getting the same results. But the problem could be on how I use this variable cSqlInsert after it is created. Here is a segment of the code:
TEXT TO m.cFileStr ADDITIVE TEXTMERGE NOSHOW FLAGS 2  

   SELECT <<cTableName>>
	
   cSqlInsert = "<<cSqlInsert>>"

  DO WHIE !eof()

         nResult = SQLEXEC(hCon, cSqlInsert)	

         SKIP

  ENDDO

ENDTEXT
I suppose the above
cSqlInsert =  "<<cSqlInsert>>"
converts the variable cSqlInsert into a long literal. Is this correct?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform