Professional Documents
Culture Documents
DBMS LAB
PAGE NO:
O8NA81A0570
DBMS LAB
Write a pl/sql block of code to select student marks from the table and print for those who secured first class and an exception can be raised if no records were found.
SQL>ed stud declare no student.Sno % type:=&no; name student.Sname %type; m1 student.mar1 %type; m2 student.mar2 %type; m3 student.mar3 %type; tot number(4):=0; avg number(6,2); begin select sno,snme,mar1,mar2,mar3 into no,name,m1,m2,m3 from student where sno=no; tot:=m1+m2+m3; avg:=tot/3; case when avg>60 then dbms_output.put_line(1 division); when avg<60 and avg>35 then dbms_output.put_line(2 division); else dbms_output.put_line(3 division); end case; EXCEPTION When No_data_found then Dbms_output.put_line(no record found); End; / SQL>SELECT * FROM STUDENT; SNO -------101 102 103 104 SNAME -------------KEERTHI TEJASWI HUDA SREE M1 -----90 89 67 74 M2 M3 ------- -----80 79 67 78 78 56 40 60
OUTPUT:
PAGE NO:
O8NA81A0570
DBMS LAB
SQL>@ stud Enter value foe no : 101 Old 100:no:=&no; New 100:no:=101; Total is 249 First class PL/SQL procedure successfully complete. SQL>/ Enter value for no:106 Old 100:no:=&no; New 100:no:=106; No record found PL/SQL procedure successfully completed.
PAGE NO:
O8NA81A0570
DBMS LAB
PAGE NO: