RDBMS SOLUTION


ASSIGNMENT 1 

SET B Q.2 SOLUTION

Write a PL/SQL block which will accept roll number of a student and display record of student from student table( use %ROWTYPE attribute)




Source code:

    

         /*set b Q.2 solution

 

     in this question,will use %type(used for extrracting data type of a particular table)

        will also use if..then..elsif..then..else statement*/

/*declaring variables*/

declare

roll_no number:=:roll_no;

std_name student.sname%type;

std_per student.sper%type;

grade varchar2(5);

/*execution section*/

begin

select sname,sper into std_name,std_per from student where rno=roll_no;

if(std_per>=90) then

grade:='A';

elsif(std_per>=80)then

grade:='B';

elsif(std_per>=70)then

grade:='C';

else

grade:='D';

end if;

dbms_output.put_line('Roll No     Name    Percentage    Grade');

dbms_output.put_line(roll_no||'        '||std_name||'        '||std_per||'         '||grade);

end;

   

    
 Download code         next