Help Needed in Date Variable [message #685634] |
Mon, 21 February 2022 21:04  |
 |
born2achieve
Messages: 4 Registered: July 2012
|
Junior Member |
|
|
Hello,
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;
begin
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 ;
end;
for security purpose, i masked the table name.
I am getting the below error when i ran the query.
Quote: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  |
 |
Michel Cadot
Messages: 68418 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
The error is:
Quote:an INTO clause is expected in this SELECT statement
In addition, using TO_DATE on a DATE variable or expression is an error.
|
|
|