Hi!
Your syntax is wrong just as oracle sais it is.
You cant use case in the where clause.
Also END is wrong it should be END CASE;
I'll give a shorter example of what happens with your syntax.
SELECT count(*)
INTO pos_count
FROM lawson.pabudget
WHERE company = 210
AND position = fte_rec.position
AND process_level = fte_rec.process_level
AND (CASE when end_date > effect_date
THEN (CASE when end_date > date_stamp
THEN to_char(end_date,'YYYYMMDD
ELSE to_char(date_stamp,'YYYYMM
END);
Let's satisfy with that.
Now we pretend that end_date is 'bigger' than both effect_date and date_stamp.
The select would then in text form look like this:
SELECT count(*)
INTO pos_count
FROM lawson.pabudget
WHERE company = 210
AND position = fte_rec.position
AND process_level = fte_rec.process_level
AND to_char(end_date,'YYYYMMDD
Oracle won't understand what youmean and therefor give out an error.
CASE is for use in PL/SQL block, and there isn't much use of CASE whne using it like IF statements.
Let's say you have cursor you are looping through.
If one condition arrives you want to do that, another you want to do this.
Instead of:
IF x=1 THEN blah
ELSIF x=2 THEN blah
ELSIF x=3 THEN blah
ELSE blah
END IF;
We in 9i can do this:
CASE x
WHEN 1 THEN blah
WHEN 2 THEN blah
WHEN 3 THEN blah
ELSE
blah
END CASE;
Case is used to create nicer code IF, ELSIF works just as good.
I'm not sure about performace in PL/SQL but in C/C++ using a case instead of IF,ELSE IF is major performance boost.
Hope this helps to explain.
If you tell us what it is you want to do, it's easier to help.
Regards
/Hans - Erik Skyttberg
Main Topics
Browse All Topics





by: itmenonPosted on 2003-03-04 at 13:08:40ID: 8067268
Hi dbrower,
The error is becuase your PL/SQL version is not supporting the CASE statement.Starting with Oracle9i, PL/SQL supports the use of case statements and case expressions.But same can be achieved by stored functions.For example in your case call a function and pass the dates as parameters and let the function to determine whether its a true condition.
For example
function check_date(d1 in date,d2 in date,d3 in date) return number is
result number := 0;
begin
--check what ever u want
if d1 > d2 then
if d1 > d3 then
result := 1;
else
result := 0;
end if;
end if;
return ( result );
end;
then in the query
select ...
from ..
where condns... and
check_date = 1;
-itmenon