CASE in pl/sql [message #39046] |
Mon, 10 June 2002 05:20 |
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 |
|
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>
|
|
|