Home > Ask the Oracle Database / Applications Experts > Oracle PL/SQL Questions & Answers > CASE in definition of cursor
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

CASE in definition of cursor

Advice from previous expert, Greg Williams EXPERT RESPONSE FROM: Advice from previous expert, Greg Williams

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site


Oracle tips, scripts, and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


>
QUESTION POSED ON: 20 November 2006
Why isn't CASE supported by PL/SQL in definition of cursor? I used the following command:
declare
temp varchar2(100);
cursor cDet is
select
case    when length('pippo - pluto - paperino')>5   then 'OK' else 'NO'
END
from dual;
begin
open cDet;
fetch cDet  into temp;
    WHILE cDet%found LOOP
        dbms_output.put_line(temp);
        fetch cDet into temp;
    end loop;
    close cDet;
end;
It doesn't work, but if I use the following one it works fine:
select
case    when length('pippo - pluto - paperino')>5   then 'OK' else 'NO'
END
from dual
Why?

>
The case statement is supported by PL/SQL. The problem may be with your PL/SQL procedure. The below procedure works:
declare
   temp varchar2(100);
   cursor cdet is
     select 
    case 
       when length('pippo - pluto - paperino' )>5 then
          'OK'
        else
            'No'
    end
from dual;
begin
    open cdet;
      fetch cdet into temp;
       -- while cdet%found loop
         dbms_output.put_line('temp '||temp);
         --   fetch cdet into temp;
       -- end loop;
        
      close cdet;
end;


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
Oracle PL/SQL
How to concatenate rows into a single CLOB in PL/SQL
Working with substitution variables and using EXECUTE IMMEDIATE in PL/SQL
How to open a ref cursor in a PL/SQL procedure
Converting Long Raw to Blob
Parsing in Oracle
ORA-01422 error when procedure returns more than one row
Definition of force view
ORA-04082: NEW or OLD references not allowed in table level triggers
Execute SQL statement from table in other schema
Script to revoke access from user

Using Oracle PL/SQL
Oracle tutorial library: SearchOracle.com's learning guides
SELECT statement syntax and examples
Oracle PL/SQL tutorial
PL/SQL datatypes in Oracle
Stored procedures in PL/SQL
PL/SQL functions and triggers in Oracle
How to concatenate rows into a single CLOB in PL/SQL
How to open a ref cursor in a PL/SQL procedure
Working with substitution variables and using EXECUTE IMMEDIATE in PL/SQL
Oracle's free SQL Developer adds database migration tool

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
PL/SQL  (SearchOracle.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Oracle White Papers: Fusion Middleware
HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts