Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A simple error...
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00800984
Message ID:
00800991
Views:
15
Ric,

In cases like this where I have to create a large string with values embedded in it, I use the TEXTMERGE command to build the statement. This way you don't have to do the string conversions and the code is much easier to follow (ie, less error prone).

example:
TEXT TO lcSqlString TEXTMERGE NOSHOW
INSERT INTO phone (phon_phoneid, phon_personid) VALUES (<<ln_last + 1>>,<<ln_1>>,'<<lc_bus>>')
ENDTEXT

myresult = SQLEXEC(1,lcSqlString)
HTH,
Kurt

>Thanks Dave!!!
>
>Sometimes the extra eyes make it go....
>
>:-)
>
>Ric
>
>>Ric,
>>
>>You have to quote the text fields:
>>
>>myresult = SQLEXEC(1,'Insert INTO phone (phon_phoneid, phon_personid, phon_type) VALUES (' + STR(ln_last + 1) + ', '+ STR(ln_1) + [, ']+ lc_bus + [')] )
>>
>>And I assume you did not nave that excess , in your field list.
>>
>>>Then I try and add a character variable into a character field and get a syntax error:
>>>
>>> myresult = SQLEXEC(1,'Insert INTO phone (phon_phoneid, phon_personid, , phon_type) VALUES (' + STR(ln_last + 1) + ;
>>> ', '+ STR(ln_1) + ', '+ lc_bus + ')')
>>>
>>>This doesn't work.
>>>
>>>
>>>Do you know how to format this correctly to get the variable value going through?
Previous
Reply
Map
View

Click here to load this message in the networking platform