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:
01526049
Vues:
69
>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 :-)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform