Forum OpenACS Q&A: Re: Bind variable from array

Collapse
Posted by Gustaf Neumann on
The short answer is that you can't use "array references" as bind vars.

The slightly longer answer is: use the bind flag. Here is the variant with arrays:

array set f {ee 3 ie 10 oe 2}
db_string no_luck {select :ie from dual} -bind [array get f]
In many cases, Tcl dicts are the better choice than Tcl arrays: use e.g.
set d [dict create ee 3 ie 10 oe 2]
db_string no_luck {select :ie from dual} -bind $d
Last but not least, one can use also ns_sets:
set s [ns_set create vars ee 3 ie 10 oe 2]
db_string no_luck {select :ie from dual} -bind $s
All this works at least in the PostgreSQL driver, but i would be surprised, when ns_ora would fail.

Hope this helps
-g