blogs.conchango.com

welcome to the conchango blogging site
Welcome to blogs.conchango.com Sign in | Join | Help
in Search

Jim 2.0

PL SQL: Passing variables in TOAD for Oracle

I regularly need to pass variables into my queries, and when running multiple tests, it helps to have a way to change these variables easily, preferably, without having to go through the query each time and change the sql. Fortunately for me TOAD (Tool for Oracle Application Developers) for Oracle offers a way to do this with bound variables. Unfortunately, it does not seem to be enabled as a default setting, which means you have to set it yourself in the options. Frustratingly too, for some reason the setting seems to switch itself back off periodically too. Every time this happens, it confuses me briefly until it occurs to me to check, and every time I have to check I forget where in the options this feature lives, so here is how you change it.

In TOAD, select View>Options; in the pop-up that appears navigate to SQL Editor>General in the tree hierarchy; check the box "Scan statements for bound variables before execution" in the second set of options (as shown below).

 To include a bound variable in a query simply precede it with an '&' e.g. '&date', and when you execute the query you will be prompted to enter the variable; in this case the date

 

Not difficult at all, but very, very useful.

 James

Published 10 February 2007 03:30 by James.Pipe
Filed under: , , , ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Jim 2.0 said:

As part of my current role as a tester I am often required to write the same basic expressions again

February 10, 2007 05:45
 

Jim 2.0 said:

As promised in my original post on PL/SQL date ranges previously, below is a sql statement which can

March 1, 2007 16:22

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server (Personal Edition), by Telligent Systems