Home » SQL & PL/SQL » SQL & PL/SQL » Help Needed in Date Variable
Help Needed in Date Variable [message #685634] Mon, 21 February 2022 21:04 Go to next message
Messages: 4
Registered: July 2012
Junior Member

version : 19C

I am trying yo capture a date from one of the query and assigning it to date variable and wanted to pass the variable in another Query. below is the sql that i gave a try
declare EXTRACTION_DATE date;

  SELECT max(end_date)  into EXTRACTION_DATE from cxadmin.cycle_count_period;  
   SELECT id, start_date, end_date, trunc(end_date) -
      trunc(start_date)  as period, 
TRUNC(TO_DATE(ADD_MONTHS(TO_DATE(EXTRACTION_DATE), -11 )),'MM') as PeriodFirstDate        
  FROM  cxadmin.cycle_count_period where trunc(end_date) -
      trunc(start_date) >= 60 order by start_date asc ;

for security purpose, i masked the table name.
I am getting the below error when i ran the query.

Error at line 1
ORA-06550: line 11, column 4:
PLS-00428: an INTO clause is expected in this SELECT statement
Please let me know what mistake am i doing in here. your reply will be highly appreciated.
Re: Help Needed in Date Variable [message #685635 is a reply to message #685634] Tue, 22 February 2022 00:34 Go to previous message
Michel Cadot
Messages: 68207
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

The error is:

an INTO clause is expected in this SELECT statement

In addition, using TO_DATE on a DATE variable or expression is an error.

Previous Topic: Getting ORA-24374 , when using function in with query (merged)
Next Topic: Let's promote them all !
Goto Forum:

Current Time: Wed Jun 29 10:31:03 CDT 2022