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:
01526059
Vues:
64
>>>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.

What is the exact desired output of this PRG?
select myTable1
SCAN
    sqlexec(hConn, 'insert into SQLTable1 (Field1, Field2,..)   values (?myTable1.Field1, ?myTable2.Field2)')
EDSCAN

select myTable2
SCAN
    sqlexec(hConn, 'insert into SQLTable2 (Field1, Field2,..)   values (?myTable2.Field1, ?myTable2.Field2)')
EDSCAN
So, this is what we want to get as the output? This is not going to work, so our prg output must be
text to lcInsert
   insert into mySQLTable1 (field1, field2,...)
   values (....)
endtext

select myTable1
  SCAN
      sqlexec(nConn, lcInsert)
 EDNSCAN
So, this is what we should get as our prg output - it's a bit tricky to produce this string based on DataDict table, but it's possible. You just need to know what you need to get as output (case 2) and then go for it.

This is a technique I always use when I'm writing dynamic SQL. I need to envision the resulting output and then it becomes simpler to get it.
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