Home » SQL & PL/SQL » SQL & PL/SQL » CASE in pl/sql
CASE in pl/sql [message #39046] Mon, 10 June 2002 05:20 Go to next message
Geoff
Messages: 11
Registered: December 2001
Junior Member
What does the syntax look like for a CASE in PL/SQL??
I'm trying to create an SP which accepts 1,2,3 or 4, and then do one of four things depending on the value: insert, update, delete, check for constraints......
I can't get DBA studio to accept the standard examples on the net.......any suggestions??
Re: CASE in pl/sql [message #39047 is a reply to message #39046] Mon, 10 June 2002 06:02 Go to previous message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
SQL> declare
  2    achar char(1) := '&achar';
  3    description varchar2(20);
  4  begin
  5    description := 
  6       case achar
  7          when 'A' then 'Excellent'
  8          when 'B' then 'Very Good'
  9          when 'C' then 'Good'
 10          when 'D' then 'Fair'
 11          when 'F' then 'Poor'
 12          else 'No such grade'
 13       end;
 14     dbms_output.put_line('The description was ' || description);
 15  end;
 16  /
Enter value for achar: B
old   2:   achar char(1) := '&achar';
new   2:   achar char(1) := 'B';
The description was Very Good

PL/SQL procedure successfully completed.

SQL> 
Previous Topic: How to use LIKE function for LONG datatype
Next Topic: Urgent Date Problem
Goto Forum:
  


Current Time: Tue Apr 23 20:31:31 CDT 2024