Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

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

  




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 Khokhar857
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Vinoth Kumar357
  Gopu Gopi340
  Gitesh Trivedi322
  neeraj sharma258
  Ramesh Jois246






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software