Hello Ventuzians!
THE FORUMS ARE CLOSED!

Please join our discord server HERE!! << click me :D

We are shutting our Ventuz Forum, but don't worry, it will all be archived for you to search in if you have a query. From now on, please add all your comments, questions or observations into our Discord Server

Thanks for the great time - see you on discord!!
Dee, Karol, Daniel and the whoooole Product and Support team!

How to use Variables in MySQL queries?

Q and A about functionality and how to solve a special task for your application.

Moderator: Support

Post Reply
schub
Posts: 54
Joined: 02 Feb 2012, 11:43

How to use Variables in MySQL queries?

Post by schub » 21 May 2014, 12:34

Hi,
Im experimenting with databases in Ventuz, most of the stuff I tried works fine, but theres one major problem:
I cant use variables in a query.

In the example scene you guys created a variable "@Clubs" and used that in the query.
When i try to add another variable with a @-prefix i get this error
character_error.JPG
Without @-prefix the variable is just ignored.

Is this a bug in the Script Editor to not allow @ for SQL or am I doing something wrong?

Greets
Schub

User avatar
Karol
Posts: 640
Joined: 10 Jan 2012, 12:07

Re: How to use Variables in MySQL queries?

Post by Karol » 22 May 2014, 12:34

Oh yeah!
This issue slipped in in Ventuz 3.7.0.
Will be fixed for upcoming Ventuz 4.4.0.

Cheers
Karol

schub
Posts: 54
Joined: 02 Feb 2012, 11:43

Re: How to use Variables in MySQL queries?

Post by schub » 22 May 2014, 17:04

Ok, good to know :D
Thanks

Greets,
schub

User avatar
Götz_B
Posts: 180
Joined: 21 May 2013, 13:01

Re: How to use Variables in MySQL queries?

Post by Götz_B » 23 May 2014, 09:34

In the meantime just use variables without a leading @.
Should work if you choose a name that's not used in the database table already.

Cheers,
Götz

schub
Posts: 54
Joined: 02 Feb 2012, 11:43

Re: How to use Variables in MySQL queries?

Post by schub » 26 May 2014, 14:32

Götz_B wrote:In the meantime just use variables without a leading @.
Should work if you choose a name that's not used in the database table already.
Sadly, it does not work for me :(

I created a variable "x" as Integer in the inputs of the query node, then when I use the following query, the error event flashes and no data is written to the database

Code: Select all

UPDATE testdb.debug SET testvalue = x WHERE debug.id = 1;
If I include the quotation marks, like phpMyAdmin uses in its querys, data is written, but instead of the value of "x" it's always changed to "0"

Code: Select all

UPDATE testdb.debug SET testvalue = 'x' WHERE debug.id = 1;
When the value is hardcoded like this, it works fine

Code: Select all

UPDATE testdb.debug SET testvalue = 1234 WHERE debug.id = 1;
At the moment my workaround is based on the "convert to text" node, which lets me edit the query string without opening the editor.
But I dont know how efficient this is, and I'm bound to the numeric variables provided by "convert to text"

Greets,
schub

schub
Posts: 54
Joined: 02 Feb 2012, 11:43

Re: How to use Variables in MySQL queries?

Post by schub » 13 Jun 2014, 15:08

Sorry I have to bring this up again, but the problem persists.

After the 4.04 update its possible to create the @variables, but they will not be used in the query.

The entries will be changed to '0' or I get an error message, depending if I used the 'UPDATE' command or 'INSERT INTO'

The only way to use an @variable is to 'SET' it first in the query like this:

Code: Select all

SET @variable=1234;
UPDATE testdb.debug SET testvalue = @variable WHERE id = 1;
This proves that variables are supported by the MySQL server, but again, if the variable values need to be hardcoded into the query they're useless for Ventuz integration.

Can someone post an example how to use Custom Model Input with a MySQL query?
Or is this not intented at all, and we're only supposed to use the Custom Model Output of the query node?

Greets
Schub

Post Reply