Friday, October 16, 2015

How To Use Decode in PL SQL

DECLARE
l_maths number;
l_eng number;
l_hindi number;
l_sci number;
l_soc number;
l_san number;
l_tot_mars number;
mark_percent number;
grade number :=100;
BEGIN

select maths,eng,hindi,sci,soc,san,tot_mars into l_maths,l_eng,l_hindi,l_sci,l_soc,l_san,l_tot_mars
from student where stud_id = :v_stud_id;

mark_percent := l_tot_mars/ 600;

 CASE
  
   when (mark_percent >= 75) then             dbms_output.put_line('Excellent');
   when mark_percent <=75 and mark_percent >=60 then dbms_output.put_line('Very good');
   when mark_percent <=60 and mark_percent >=50 then dbms_output.put_line('Well done');
   when mark_percent <=50 and mark_percent >=40 then dbms_output.put_line('You passed');
   when mark_percent <=40 and mark_percent >=35 then dbms_output.put_line('Better try again');
   else dbms_output.put_line('No such grade');
   END CASE;

END stud_pro;

No comments:

Post a Comment

Clear BNE Cache for WebADI Changes

It Sometime happens that WebAdi Changes doesn't reflect once migrated in controlled instances. Here are the quick steps(Generally perfor...