Toad Automation Script - using Variables in Sql query (Export Wizard)

Hello,

I have a Toad Script where (for test reasons) I’ve set a “Set_Variable_1” activity with a Variable name “table” and the String value “Students”. Then I put the " Export Wizard" with a simple query which should export table content to excel file. I’ve put a simple query using the variable but I’m getting an error. Will you tell me what I’m doing wrong? What I tried till now is:

select * from :table

select * from [tag:table]

select * from %table%

But none of them is working. I noticed however that if I use the variable in the query in WHERE section it works fine. E.g.:

select * from students where status = :table

It’s returning correct values

The goal is to run this query in several tables which I want to provide as the variables thus I need automation.

if this was an Oracle connection you could use the following:

select * from &table

i though we coded the ‘&’ as a replacement literal symbol for all connection types. But i tried this on DB2 LUW and this didn’t work.

Try this. This works in the editor. (Dont’ ask about the funny syntax. This is from internal Toad scripting language that is used internally only.)

select * from {{Unquote(:dbname)}}