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:
01526057
Vues:
61
>>>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?
select ListOfTables

scan
   select (ListOfTables.TableName)
   lcInsert = GetInsertStatement(ListOfTables.TableName)
   scan
       SQLEXEC(hCon, m.lcInsert) 
  endscan
endscan
This is if you want to transfer each table each record using this very slow approach.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform