Posts:
1
Registered:
3/20/13
|
|
|
|
Can't set variable in data tab of Toad Report
Posted:
Mar 20, 2013 10:07 AM
|
|
|
I created a report in TOAD but I need to set a variable in the query. I modified my code and it executed fine in the MySQL backend, but when I edit the data section of the report and add the same code, it gives me an error and keeps my set statement and erases all code associated with the select statement that built the report.
I know you can in MySQL:
set @variable = 1;
select * from table
where value = @variable;
all at the same time but not letting me in TOAD report...any help or ideas?
|
|
|
Posts:
1,974
Registered:
2/15/07
|
|
|
|
Re: Can't set variable in data tab of Toad Report
Posted:
Mar 25, 2013 8:30 AM
in response to: ony12
|
|
|
|
|
The Data Reports use single SQL statements and not blocks of code where params might be defined.
To use a variable in Toad Data Reports, bind to the variable using a colon. When executing you will be prompted to enter the bind value.
When using a bind var in Automation you will need to use a Set Variable activity and define a variable with the same name as the var you used in your query. I am not sure if you want to automate this report but I thought I would add that.
Debbie
|
|
|
Posts:
1,974
Registered:
2/15/07
|
|
|
|
Re: Can't set variable in data tab of Toad Report
Posted:
Mar 25, 2013 8:43 AM
in response to: Debbie Peabody
|
|
|
|
|
Attached is a sample script using a bind var and Toad Report. I will assume you are using TDP 3.2. Place the files in this default directory.
C:\Program Files (x86)\Quest Software\Toad Data Point 3.2\Plugins\Odbc\Sample Database
This script uses the Toad Sample database. You might have to re-point at that connection.
The script shows how to define a variable. The Toad Data Report using that same named var in the SQL. The Automation script knows how to define those together.
Get that part to work first for what you need to do. Then you will need to set the value of your bind var. This may take a loop activity. If so we can go over that too.
Debbie
|
|
|
|
Legend
|
|
Guru: 2001
+
pts
|
|
Expert: 751
- 2000
pts
|
|
Enthusiast: 31
- 750
pts
|
|
Novice: 0
- 30
pts
|
|
Moderators
|
|
Helpful answer
(5 pts)
|
|
Answered
(10 pts)
|
|