how to used Bind variable with Export

Hi ,

I am trying to used bind variable in the export wizzard.

I am trying to export using Toad automation Script.
To used bind variable with export i did follwoing.

  1. Created the bind variable “maxdate”

  2. created SQL script “maxquery.sql” with follwoing query.
    SELECT * FROM TEMP_TAB WHERE update_date=:maxdate;

  3. Used above SQL script in the export wizzard.

When i try to test the automation scripts, it throws the error.

Object reference not set to an instance of an object.
Quest.Toad.Workflow.Activities.Database.ExportWizardActivity.Execute(ActivityExecutionContext executionContext)

Could you please suggest how to fix this issue or how we can use the bind variable in the export query.


Bind variables are supported in Automation. Do you have a variable activity above the Export Wizard activity?

I would suggest turinging on verbose logging (in Script Settings) and running again. This will give me an error stack to read. Then zip up your automation file and dependent files and email to me. I will take a look.


Thanks Debbie for your response.

I have the variable activity above the export wizard.

I have attached the zip which includes all those files which i am using for automation.

I am unable to find your email id, it will be great if you can share it.

Pravin (159 KB)

Okay, I had to do a bit of experimenting but got it to work for me.

There were two problems.

  1. If you look in the log file the value being set has an extra quote in the middle of the date.
    Variable value = 12/9/“2010 1:57:00 PM”

I don’t know why this is but it seems to only occur on Sybase. To handle this you need to have your select statement surround the date in quotes and convert the date to a string. Use a SQL something like the one below.

select ‘"’ + convert(char(10), max(ORDER_DATE), 101) + ‘"’ from QUEST_DEV.dbo.ORDERS

  1. The export wizard doesn’t seem to like binds. I got the same null ref. However, the select to file works fine. I notice that you are exporting to tab delimited. Can you export to csv? The select to file will do this.

So to correct I would make a whole new script with the above changes. I attached my script for sample. If you need anything else you can send files to

Script_2.tas (8.69 KB)

Hi Debbie,
Sorry for replying it too late. The solution you have given working intelligently!
You guessed correctly I was using Sybase. Thanks Allot for your help.


Glad to hear.