Click to See Complete Forum and Search --> : case inside a cursor


vbaskar
08-07-2001, 08:16 AM
My Version

Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
PL/SQL Release 8.1.7.0.0 - Production
CORE 8.1.7.0.0 Production
TNS for Solaris: Version 8.1.7.0.0 - Production
NLSRTL Version 3.4.1.0.0 - Production


issue
------

DECLARE
CURSOR s1 IS SELECT '1','2',CASE WHEN 1=2 THEN 1 ELSE 4 END xx FROM dual
BEGIN
FOR c1 IN s1
LOOP
dbms_output.put_line('xx');
END LOOP;
END;

--I AM GETTING THIS ERROR..

ORA-06550: line 2, column 29:
PLS-00103: Encountered the symbol "CASE" when expecting one of the following:

( - + mod null <an identifier>
<a double-quoted delimited-identifier> <a bind variable>
table avg count current max min prior sql stddev sum variance
execute the forall time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string>

--The same thing works fine with a simple sql statement on EXECUTE IMMEDIATE..

bmycroft
08-07-2001, 10:15 AM
I cant remember where I read this (im looking for it now) but I thinkthat the cse statement is supported in SQL but not in PLSQL - hence your SQL is fine its the PLSQL that is the problem. As I say, I cant find the source for that but im looking :-)

vbaskar
08-07-2001, 11:21 AM
Okey...but i can still use in PL/SQL block..the restriction is i cannot use it in the CURSOR..