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:
01526047
Vues:
76
>>>>Hi,
>>>>
>>>>I am getting an error a line very similar to the following. The error says "command contains unrecognize phrase/keyword".
>>>>
>>>>
>>>>cSqlInsert = "insert into Mytable (fld1, fld2, fld3) values (?MyTable.fld1, ?MyTable.fld2, ?MyTable.fld3)"
>>>>
>>>>
>>>>The list of fields is actually considerably longer. But what should I be looking at? TIA.
>>>
>>>
>>>The string literal can not exceed 256 chars,
>>>Try to put this in TEXT ENDTEXT block
>>>
>>>TEXT TO cSqlInsert NOSHOW PRETEXT 15
>>>    insert into Mytable 
>>>           (fld1, fld2, fld3)
>>>    values 
>>>           (?MyTable.fld1, ?MyTable.fld2, ?MyTable.fld3)
>>>ENDTEXT
>>>
>>>
>>>BTW that way is more readable :-)
>>
>>You are probably right. But in my case the string " insert ...." is created with the TEXT TO / ENDTEXT while scanning all fields of the table. So the resulting expression is very long. I am a little at loss right now as to how to change it. Thank you for your help.
>
>Can you post the longer code that is failing and the exact line of the failure?

The problem, as Boris correctly pointed, is that my expression
cSqlInsert = "insert into Mytable (fld1, fld2, fld3) values (?MyTable.fld1, ?MyTable.fld2, ?MyTable.fld3)"
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?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform