Toad World® Forums

Bind Variables not working for MySQL

I'm using Toad Data Point 5.0.4.45, and MySQL 5.7

I'm trying to use Loop Dataset to pull a list of values to iterate over to perform queries with in MySQL. Following the tutorial on youtube as an example, I have a loop data set with a driving query that returns 3 rows with 2 columns. The column of interest is 'flow_name' and I've named the dataset variable 'OpenFlows'.

In my child action I have a Select to File, with a simple query:

Select * from table WHERE flow_name = :OpenFlows.flow_name

I've also tried @OpenFlows.flow_name and #OpenFlows.flow_name#

None are working, it's as if the variable value isnt being passed. I'm getting 0 rows exported. Is there some other way we're meant to supply variables to a query?

First thing comes to mind:

Since your variable is "OpenFlows", you'll need to de-reference it with surrounding pounds... e.g.
#OpenFlows#.flow_name

De-reference, meaning WHERE flow_name = #OpenFlows#.flow_name ?

Yes, as in ::
Select * from table WHERE flow_name = #OpenFlows#.flow_name

Select * FROM wfe_oi.wfe_flows_repeats_summary_new
WHERE flow_name = #OpenFlows#.flow_name
LIMIT 20;

This gives a dbms error:
2/14/2020 8:30:47 PM: 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 'flow_name
LIMIT 20' at line 2

Edit:

I'm a dummy - I was using a stored procedure to pull the rows in for the loop, and forgot the "flow_name" column was actually labeled "value".. I altered my procedure to name the column "flow_name" and using :OpenFlows.flow_name now works as expected.