Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PL SQL SELECT statement with variable; without using SELECT INTO

94b75cd4-86be-4844-98a5-e978d8a27cf3Mar 31 2019 — edited Mar 31 2019

I need a simple query. Just a select statement but with several unions each having the same date filter. I would like to declare the date at the beginning of the script. I don't have permission to create a table hence SELECT INTO won't work. I tried the below:

DECLARE

     stdt date := SYSDATE;

Begin

     select * from tbl

     where til_date < stdt;

End;

I have used SYSDATE just for representation. I need to use different dates in place of SYSDATE and there are n number of unions. Hence I require date to be declared at the start. The problem with the above query is that I don't have access to create table and hence can't use SELECT INTO. Please help me how to achieve this.

Comments
Post Details
Added on Mar 31 2019
6 comments
11,947 views