Bind columns in SQL variables? (AE v9)

This is probably a crazy question because I don't really know what I'm talking about. But maybe someone who does will indulge me. :-)

We essentially want to repeat a SQL query to a production database every few minutes, and when it returns a certain result, then run a job (but we don't want to run an actual job to do the query that often, because this particular workflow has about 300 instances active at any given time).

So were thinking to put it in a SQL variable, and use that in a pre-condition.

(P.S. this function is currently done by 300 perl jobs running in parallel, doing the check every few minutes, which seems like a perfectly reasonable approach. But there are long-story problems with it.)

I implemented one of these just yesterday against an Oracle database. Works slick and we are having no problems. Our SQL also has variable WHERE conditions which we bring into the SQL with UC4 variables. I think this ability to bring in dynamic variables is what a DBA might call a "bind variable"?

But how do you bind a column (I don't really know what I'm asking)? In the perl script I see several steps with comments like "execute and bind columns"... "define binding variables"... not sure what is really happening behind them.

You don't need to do anything more. Just set it up and
test it to prove to everyone it works. You may need to show it to the DBAs to give them another chance to voice their concerns, but they really shouldn't have any.

In our case we needed to know an asynchronous process had
completed before going on. We did it
with a “SELECT COUNT(*) FROM table WHERE conditions” to select incompleted rows, and if it returns a “0”,
then we know the asynchronous process has completed.