Help with variables in PL/SQL

From: Morgan Clark <swayzack1_at_yahoo.com>
Date: 19 Jun 2003 11:37:32 -0700
Message-ID: <11203f39.0306191037.3e9758fb_at_posting.google.com>


Hi... I'm trying to do what I consider to be a real simple thing, but I can't get it to work right! I have a query that I'm going to have to run every now and then - I just have it saved as a text file that I'm going to copy and paste into SQL/Plus when I need to. Not the best way, I know, but we have very limited permissions to the actual database (it's a data warehouse hosted offsite)...

In my query, I look at a certain date a bunch of times. I'd love to make it a variable. In T-SQL (what I'm used to), I could do something like:
DECLARE _at_theDate datetime
SET _at_theDate = '5/30/2003'

SELECT whatever
FROM wherever
WHERE thisdate > function(_at_theDate) AND thatdate <= function(@theDate)

... point is, I reference the same date in the SELECT a whole bunch of times, and it'd be nice to just set it once. The research I've done on Oracle all has examples of declaring a variable, then using SQL that either returns one row, or manipulates data in some way - nothing that just returns a set of data in a SELECT. I've read about cursors, but they seem to be used just to loop through the results and manipulate the data... I just want to display the result of a SELECT statement that I'm using a variable in. Can somebody help me out??? I know this is a stupid question, and I apologize, but it's such a stupid question that it's tough to find the answer to....... Thanks. Received on Thu Jun 19 2003 - 20:37:32 CEST

Original text of this message