Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What could cause error on this line
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01526039
Message ID:
01526049
Views:
71
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform