Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

In Oracle SQL Developer, can a query be assigned to a variable for re-use?

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
This tiny ad is wafer thin:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic