Named Query - MySQL SET Variable Not Working

Is it not possible SET a variable in a SQL query? This does not seem to work but works fine on my server directly.

SELECT @foo :=1;
SELECT @foo

or

SET @foo = 1;
SELECT @foo

image

MySQL JDBC drivers can only perform one “transaction” at once. I once tried to run an update query then a delete from query on the same table in one named query, but it would not work. I had to break them up into two separate named queries. I tried this and it works select @foo := 1, @foo2 :=3 It looks like that if you want to run something like what you had, you will probably will have to set it up as a stored procedure in the DB then call it from ignition.

2 Likes

A similar issue was posted not too long ago with the following better explanation.

1 Like

Thanks a lot, figured it was a JDBC driver issue.

1 Like
3 Likes