Setting value to MySql
I made a simple table for testing. The table has 2 columns named A and B. The values are 1 and 2. The data is readable with both column based and row based query.
I used this statement for reading "SELECT
TestLIMIT 0, 1000 ;"
How should the update statement look like? Any examples?
I tried some statements but they did nothing or caused the following alarm "Exception while setting point TestPoint: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0)."
the SQL-Update syntax is
SET A=3, B=4
Hope this helps
Yeah, the documentation is a bit lite on the matter. You need a "?" parameter in your statement, where the parameter is value to which the point is being set.
For example, i created a table thus:
create table testTable ( c1 int, c2 int);
... and added a couple rows:
insert into testTable (c1, c2) values (1, 10), (2, 11)
Then, i created a data source with a row-based query:
select c1, c2 from testTable
... and a couple of points with row identifiers "1" and "2". On the second point i added this update statement:
update testTable set c2=? where c1=2
Then, when i go to the watchlist and set the point to "20" and then check the table contents, i see that the c2 value for the correct row is "20".
Hope this helps.
Such a small thing but thanks it helped.
Is '??' used as escape if '?' is needed in the statement? In mysql, I think there should not be such need but just curiosity.
After years of using prepared statements in many databases, i have to admin i have no idea. It never came up.