Topic: SQL*Plus and PL/SQL >> CASE statement.........
|
Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property.
You may review the entire Oracle Certification Program Candidate Agreement online Here.
|
|
|
|
| Title: CASE statement......... |
| Navi |
Posted: Jul 25, 2007 10:58:21 PM |
Total Post: 60
Joined: Jun, 2007
|
Hi,
Can anyone please help me to rectify the problem.
Hi i wrote the following code regarding CASE statement:-
declare
num number :=45;
begin
case num
when num<20 then
dbms_output.put_line('Num is less then 20');
when num<40 then
dbms_output.put_line('Num is less then 40');
else
dbms_output.put_line('Num is less then 60');
end case;
end;
/
but i got the following error:-
case num
*
ERROR at line 4:
ORA-06550: line 4, column 6:
PLS-00615: type mismatch found at 'NUM' between CASE operand and WHEN operands
ORA-06550: line 4, column 1:
PL/SQL: Statement ignored
********** In this error i think datatype mismatch occured but i dont no why it occured **********
Please help with the correct code.
Regards,
Naveen
|
|
|
Jolly |
| Posted: Jul 25, 2007 11:54:05 PM | |
|
Total Post: 24
Joined: Mar, 2007
|
Hi Naveen,
I think the following of your code after removing num from case statement worked properly.
1 declare
2 num number := 45;
3 begin
4 case
5 when num<20 then
6 dbms_output.put_line('Num is less then 20');
7 when num<40 then
8 dbms_output.put_line('Num is less then 40');
9 else
10 dbms_output.put_line('Num is less then 60');
11 end case;
12 end;
13 /
Num is less then 60
PL/SQL procedure successfully completed.
Since you have defined num as 45 only "dbms_output.put_line('Num is less then 60')" will be displayed. Before running this statement make sure that you give SET SERVEROUTPUT ON from the SQL prompt.
When you change the num value from 45 to 35 then "dbms_output.put_line('Num is less then 40')" will be displayed.
Cheers
Jolly
|
|
|
|
|
Navi |
| Posted: Jul 26, 2007 04:23:34 AM | |
|
Total Post: 60
Joined: Jun, 2007
|
Hi Jolly,
Thank you Jolly its working fine.
Regards,
Naveen
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |
|
|
|
|
Forum Rules & Description
Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user
|
| |
Get FREE Magazines
|
Top 10 Forum User
|
| Murtuja Khokhar | 857 |
| Mohammed Taj | 746 |
| positive fanatic | 483 |
| Jayanta Sur | 479 |
| Vigyan Kaushik | 386 |
| Vinoth Kumar | 357 |
| Gopu Gopi | 340 |
| Gitesh Trivedi | 322 |
| neeraj sharma | 258 |
| Ramesh Jois | 246 |
|
|