I'm attempting to declare variables for use in several scripts in the same editor. This is so that multiple updates are needed when using the script for a new user.
Here's an example of what I'm trying to use:
DECLARE
Rep_Name NVARCHAR(250);
BEGIN
Rep_Name := 'Kristi Barrickman';
SELECT REP_CODE, REP_NAME, REP_SF_ID, REP_TEAM, RESPONSE_TEAM, REP_WORKGROUP
FROM USER_LIST
WHERE 1=1
AND CURRENT_RECORD=1
AND REP_NAME = :Rep_Name;
Your question is not Toad product related, but rather database/syntax related. Nevertheless, other users may have some insight for you. One thing I have noticed is that different database platforms can treat variables differently. In your case, you're using a bind variable, which might be tripping up your objective to use the variable value in different places. See, link below, which discusses use of &var vs. :var, for example...
Hi,
Using Toad Automation, there is a very simple solution.
You declare a variable ( I would suggest using variable names that are obvious, such as REP_NAME_VAR) at the begining of the script and use the following syntax in the next steps.
where rep_name = #REP_NAME_VAR#
Sincerely,
Simon
P.S. I use this feature in most of the scripts that I use.
P.S.S. I just discovered that when I envoke an automation script from another automation script, the variable placeholders are replaced by the current value.
I assume this is a bug, but as we have not renewed our service contract, I cannot open a ticket on this issue. This should not deter you from using this famntastic feature, as I have found a way to overcome this problem.