File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Oracle/OAS and the fly likes In Oracle SQL Developer, can a query be assigned to a variable for re-use? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "In Oracle SQL Developer, can a query be assigned to a variable for re-use?" Watch "In Oracle SQL Developer, can a query be assigned to a variable for re-use?" New topic
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: 140
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: 118
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
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

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: 118
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
 
Consider Paul's rocket mass heater.
 
subject: In Oracle SQL Developer, can a query be assigned to a variable for re-use?