English 中文(简体)
Anything wrong with this SQL query?
原标题:

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 ;


问题回答

I think you need to send these as individual SQL statements, instead of all of them at once.

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.

According to Mimer Validator, your SQL is fine. My guess is that for some reason, it doesn t like the semi-colons.





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签