Question

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!

Was it helpful?

Solution

Several points:

  1. 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.

  2. After the "end;" your PL/SQL block has finished. If you want to execute another query do not put the end;

  3. 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');

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top