Community forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.

After setting a value to the JOB variable CUSTOMER_ID, I try use this JOB variable in a SQL QUERY.

select *
from business.customers
where customer_id = (JOB(Active,Variable.CUSTOMER_ID)}

The run job result in the next error message:
Exception in Task: 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 'TranslateVariables->Unhandled error: Index was outside the bounds of the array. ' at line 1

How can I pass a (JOB) variable to an SQL query?
Forum information
Your first bracket is wrong:


should be:


Generally speaking I find it easier to declare variables, and use those variables in the query. An additional advantage is that you avoid implicit type conversion. In your case the MySql engine has to convert a string to int, and this can cause performance issues in some cases. This is how it would look like in SQL Server (I don't know the syntax for MySql)

DECLARE @customerId AS INT = CAST({JOB(Active,Variable.CUSTOMER_ID)} AS INT);

select *
from business.customers
where customer_id = @customerId;
I hope thomas reply solved your issue hans, if not, let us know.

Please like  VisualCron on facebook!
Scroll to Top