| Author |
In Oracle SQL Developer, can a query be assigned to a variable for re-use?
|
Joe Vahabzadeh
Ranch Hand
Joined: Jan 05, 2005
Posts: 129
|
|
Ok, I probably should clarify what I'm doing.
I have a single SQL Query Worksheet open, and I have on that sheet something like the following:
Now, I'd like to, instead of having that first select statement copy/pasted a zillion times, assign it to a variable or a reference of some sort, so that I can have the query itself only in one place - thus any debugging or modifications of the query only have to be done once.
Is this possible? If so, how do I do it?
Thanks.
|
 |
Agador Paloi
Ranch Hand
Joined: Jan 24, 2006
Posts: 116
|
|
I would put the sql into a single class if this is all the sql you have. I usually put all sql into separate classes for each object type I need to persist in the database.
Agador
|
 |
Martin Vajsar
Bartender
Joined: Aug 22, 2010
Posts: 2329
|
|
Joe, I believe SQL developer supports (nearly all of) the SQL*plus syntax, including the COLUMN command, which can be used to declare a variable:
This at least worked in my SQL Developer (version 3.0)
There may be other ways to define a variable (eg. the DEFINE command), but I'm not very well versed in them.
|
 |
Agador Paloi
Ranch Hand
Joined: Jan 24, 2006
Posts: 116
|
|
Sorry , missed the sql + reference in your Q.
If your going to execute these queries a zillion time you may want to create a function for each in a pl sql package.
Agad
|
 |
 |
|
|
subject: In Oracle SQL Developer, can a query be assigned to a variable for re-use?
|
|
|