I am trying to declare a variable that represents a date, my code looks like this:
declare
mydate date;
begin
select TO_DATE('01.01.2014 00:00:00','DD.MM.YYYY HH24:MI:SS') into mydate from dual;
end;
--then comes code like this, the code below works when there is no declaration:
WITH *** AS
(
),
*** AS
(
)
SELECT ***
FROM ***
GROUP BY ***
UNION ALL
SELECT ***
FROM ***
WHERE ***
The code above does not work. Well i am not a pro in SQL so are there any tips? I also searched trough stackoverflow but did not find an answer.
errorlog (not that helpful):
ORA-06550: line 8, column 1:
PLS-00103: found symbol "WITH"
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
thanks!
Several points:
The second select does not have an "INTO". Why do you execute the select query in PL/SQL if you do not use the result.
After the "end;" your PL/SQL block has finished. If you want to execute another query do not put the end;
Why do you use a query to execute a function like to_date? You may had done:
mydate := TO_DATE('01.01.2014','DD.MM.YYYY');