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:
01526076
Vues:
43
>>>>>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, ) && where cSQLInsert a statement prepared with the code above
>>  endscan
>>endscan
>>
>>
>>This is if you want to transfer each table each record using this very slow approach.
>
>What I am doing is kind of what Borislav suggested in the very first reply. I manully change the literal string cSqlInsert into the TEXT MERGE.. You see I am creating a big .PRG that goes throught about 90 tables and converts them from VFP to SQL server. And some of them have so many fields that the literal string becomes too long. So I will manually change those cases to TEXT TEXTMERGE. It would be nice if I could do nested TEXTMERGE. But the VFP helps says that it is not recommended.
>
>Thank you.


No I didn't suggest you to put whole code in TEXT ENDTEXT block.
I didn't know how you created the string. I thought you have a very long line like this:
lcSQL = "some very long line created at once"
That is why I suggest you to put creation of this line in TEXT ENDTEXT.
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