问题
I'm using LabVIEW and the Database Toolkit to execute an SQL query, and it keeps barfing on this for syntax reasons. I'm using MySQL through the ODBC connector. Each line should have a newline character at the end except for the last.
The error LabVIEW is throwing is this:
Possible reason(s):
ADO Error: 0x80040E14 Exception occured in Microsoft OLE DB Provider for ODBC Drivers: [MySQL][ODBC 5.1 Driver][mysqld-5.1.42-community]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1092'; UPDATE plc_a' at line 2 in NI_Database_API.lvlib:Conn Execute.vi->UpdatePLCAddressesTable.vi->DevelopSQL.vi
UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1132'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1092'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1103'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1105'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1161'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1167'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1129'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1088'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1098'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1099'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1100'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1117'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1118'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1106'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1107'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1108'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1109'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1110'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1111'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1151'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1154'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1157'; UPDATE plc_addresses SET CurrValue = '-1023.75' WHERE Address = '1119'; UPDATE plc_addresses SET CurrValue = '-1023.75' WHERE Address = '1120'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1165'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1095'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1164'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1096'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1097'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1121'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1122'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1123'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1124'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1089'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1101'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1112'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1113'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1114'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1115'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1116'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1091'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1141'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1142'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1143'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1139'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1153'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1148'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1145'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1150'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1147'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1149'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1146'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1104'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1093'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1125'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1126'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1127'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1094'; UPDATE plc_addresses SET CurrValue = '0.00' WHERE Address = '1114'; UPDATE plc_addresses SET CurrValue = '-2522.00' WHERE Address = '1114';
回答1:
I think you need to send these as individual SQL statements, instead of all of them at once.
回答2:
ADO does not support multiple statements to be executed in a single operation, you will need to execute them sequentially one after the other. Given they are all similar you might want to use Prepared Statements.
回答3:
According to Mimer Validator, your SQL is fine. My guess is that for some reason, it doesn't like the semi-colons.
回答4:
Enable FLAG_MULTI_STATEMENTS
Reference: http://dev.mysql.com/doc/refman/5.1/en/connector-odbc-configuration-connection-parameters.html
来源:https://stackoverflow.com/questions/2150990/anything-wrong-with-this-sql-query