Week 5
Week 5
Week-5
Program:
Sample PL/SQL program:
SQL> begin
2 dbms_output.put_line('hello');
3 end;
4/
OUTPUT:
hello
PL/SQL procedure successfully completed.
Sum of two numbers:
SQL> declare
2 a integer;
3 b integer;
4 c integer;
5 begin
6 a:=2;
7 b:=3;
8 c:=a+b;
9 dbms_output.put_line('sum of'||a||'and'||b||'is'||c);
10 end;
11 /
OUTPUT:
sum of2and3is5
PL/SQL procedure successfully completed.
Table created.
SQL> insert into student_marks values(101,'ravi',560,70);
ADITYA UNIVERSITY (Formerly Aditya Engineering College (A)) ROLL NO: 23A91A0543
Exp No:
Date: Page No:
OUTPUT:
1 row created.
SQL> select * from student_marks;
OUTPUT:
STUDENT_ID STUDENT_NAME TOTAL_MARKS PERCENTAGE
101 ravi 56 70
Program for Student marks can be selected from the table and printed for who secured
first class and an exception can be raised if no records were found.
SQL>DECLARE
2 scountnumber;
3 no_records_found EXCEPTION;
4 BEGIN
6 if scount =0 then
7 RAISE no_records_found;
8 end if;
11 loop
12 dbms_output.put_line(records.student_id);
13 end loop;
14 EXCEPTION
ADITYA UNIVERSITY (Formerly Aditya Engineering College (A)) ROLL NO: 23A91A0543
Exp No:
Date: Page No:
19 END;
20 /
OUTPUT:
first class students are-----::
101
103
104
PL/SQL procedure successfully completed.
ADITYA UNIVERSITY (Formerly Aditya Engineering College (A)) ROLL NO: 23A91A0543
Exp No:
Date: Page No:
Program:5B
SQL> create table student
2(
3 rollno integer,
4 name varchar2(20) );
OUTPUT:
Table created.
SQL> rollback to b;
Output:
Rollback complete.
ADITYA UNIVERSITY (Formerly Aditya Engineering College (A)) ROLL NO: 23A91A0543
Exp No:
Date: Page No:
ADITYA UNIVERSITY (Formerly Aditya Engineering College (A)) ROLL NO: 23A91A0543