Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to execute more than 1 update with SQLEXE
Message
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01522041
Message ID:
01522044
Views:
55
>Hi,
>
>How do you string two or more UPDATE commands to be executed with SQLEXEC()? I tried separating them with ";" but I get error message. Here is my test string:
>
>
>cCommand = "update MyTable set Field1 = '111' where Field1 = '222'; update MyTable set Field2 = '111' where Field2= '222'"
>SQLEXEC( nHandle, cCommand )
>
>
>What is wrong with the above syntax? TIA.

Try using this
TEXT to lcSQL NOSHOW
   UPDATE myTable SET Field1 = '111' WHERE Field1 = '222';
   UPDATE myTable SET Field2 = '111' WHERE Field2 = '222';
ENDTEXT

if SQLEXEC(nHandle, m.lcSQL) <0 
   &&Check the actual error with aerror()
ENDIF
I think your code was OK also, but better to write them as separate lines and you should always check the return value of SQLExec.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform