0% found this document useful (0 votes)
9 views

Adbms Lab

Uploaded by

jason beryl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Adbms Lab

Uploaded by

jason beryl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 80

1.

Consider the following schema for Company Database:

EPLOYEE DLOCATION
Name Constraint Name Constraint
SSN Primary Key DNo Foreign Key refers Department, Part of
EName Not Null Primary Key
Address Not Null DLoc Not Null, Part of Primary Key
Gender Must be in (f, m)
Salary Not Null, must be >0 Note: A department can be in many locations
SuperSSn Foreign key refers to Employee
DName Foreign Key refers
Department(DName)

DEPARTMENT PROJECT
Name Constraint Name Constraint
DNo Primary Key PNo Primary Key, must begin with P
DName Unique PName Unique
MgrSSN Foreign Key refers to Employee PLocation Not Null
MgrStartDate Not Null DNo Foreign Key refers to Department

WORKS_ON
Name Constraint
SSN Part of Primary Key, Foreign Key
refers to Employee
PNo Part of Primary Key, Foreign Key
refers to Project
Hours Not Null, must be >0

Note: Give names to constraints

Write SQL queries to


1. Make a list of all project numbers for projects that involve an employee whose last name is ‘Scott’, either
as a worker or as a manager of the department that controls the project.
2. Show the resulting salaries if every employee working on the ‘IoT’ project is given a 10 percent raise.
3. Find the sum of the salaries of all employees of the ‘Accounts’ department, as well as the maximum salary,
the minimum salary, and the average salary in this department
4. Retrieve the name of each employee who works on all the projects controlled by department number 5 (use
NOT EXISTS operator).
5. For each department that has more than five employees, retrieve the department number and the number of
its employees who are making more than Rs. 6, 00, 000.

Write PL/SQL program


1) To compute the DA, HRA, Tax and Net pay of employees. Given HRA is 10% of Basic pay, DA is 12% of
Basic pay, Tax is 10% of Basic pay.
2) To display all employee names along with their immediate supervisor names if they have or display “Super
Boss” for those who do not have immediate supervisors.
3) Trigger to insert old manager information such as Manaer_id, Manaer_name, dept_no, dept_name and
startdate and end date(new managers start date – 1 day) into a new table Manager_Info when manager_id
of a dept is updated.

SQL> CREATE TABLE Emp


2 (SSN varchar(10)primary key,

3 EName varchar(10)not null,

4 Address varchar(10)not null,

5 Gender char(1)constraint g_char check(Gender IN('f','m')),

6 Salary number(10,2)not null constraint sal_emp check(Salary>0),

7 SuperSSn varchar(5)constraint superssn_emp references emp,

8 DName varchar(10));

Table created.

SQL> CREATE TABLE dept

2 (DNo varchar(10)primary key,

3 DName varchar(10)constraint dname_dept unique,

4 MgrSSn varchar(10)constraint mgs_dept references emp,

5 MgrStartDate date not null);

Table created.

SQL> ALTER TABLE emp ADD CONSTRAINT DName_emp foreign key(DName)references dept(DName);

Table created.

SQL> create table DLocation

2 (dno varchar(10)constraint dnum references department,

3 dloc varchar(15)not null,

4 primary key(dno,dloc));

Table created.
SQL> desc DLocation;

Name Null? Type

----------------------------------------- -------- ----------------------------

DNO NOT NULL VARCHAR2(10)

DLOC NOT NULL VARCHAR2(15)

L> create table projectt

2 (Pno varchar(10)primary key constraint pno_pk check(Pno like('P%')),

3 Pname varchar(20)constraint pname_uk unique,

4 PLocation varchar(20)not null,

5 DNo varchar(10)constraint dno_fk references dept);

Table created.

SQL> create table workson

2 (SSN varchar(10)constraint ssn_con references emp,

3 PNo varchar(10) constraint pno_con references projectt,

4 Hours number(10)constraint hrs_con check(Hours>0)not null,

5 primary key(SSN,PNo));

Table created.

SQL> insert into emp values('&SSN','&EName','&address','&Gender',&Salary,'&SuperSSN','&DName');

Enter value for ssn: e114

Enter value for ename: ankitha

Enter value for address: udupi

Enter value for gender: f

Enter value for salary: 350000


Enter value for superssn: e102

Enter value for dname:

old 1: insert into emp values('&SSN','&EName','&address','&Gender',&Salary,'&SuperSSN','&DName')

new 1: insert into emp values('e114','ankitha','udupi','f',350000,'e102','')

1 row created.

SQL> select *from emp;

SSN ENAME ADDRESS G SALARY SUPER DNAME

---------- ---------- ---------- - ---------- ----- ----------

e001 marie manipal f 960000

e101 sammy udupi m 710000 e001

e102 mark scott manipal m 740000 e001

e111 aana uchila f 430000 e101

e112 rocky kundapur m 150000 e101

e113 mahesh mulki m 360000 e102

e114 ankitha udupi f 350000 e102

7 rows selected.

SQL> update emp set DName='Sales' where SSN='e114';

1 row updated.

SQL> select *from emp;

SSN ENAME ADDRESS G SALARY SUPER DNAME


---------- ---------- ---------- - ---------- ----- ----------

e001 marie manipal f 960000

e101 sammy udupi m 710000 e001 Accounts

e102 mark scott manipal m 740000 e001 Sales

e111 aana uchila f 430000 e101 Accounts

e112 rocky kundapur m 150000 e101 Accounts

e113 mahesh mulki m 360000 e102 Sales

e114 ankitha udupi f 350000 e102 Sales

e103 allen manglore m 920000 e001 IT

e115 amrutha barkur f 700000 e103 IT

e116 sonali mulki f 450000 e103 IT

e117 anush kaup m 650000 e103 IT

11 rows selected.

update emp set DName='IT' where SSN='e118';

1 row updated.

SQL> update emp set DName='IT' where SSN='e119';

1 row updated.

SQL> update emp set DName='IT' where SSN='e120';

1 row updated.

SQL> update emp set SSN='e121' where SSS='121';

update emp set SSN='e121' where SSS='121'


SQL> update emp set SSN='e121' where SSN='121';

1 row updated.

SQL> update emp set DName='IT' where SSN='e121';

1 row updated.

SQL> select *from emp;

SSN ENAME ADDRESS G SALARY SUPER DNAME

---------- ---------- ---------- - ---------- ----- ----------

e121 je scott manipal m 650000 e103 IT

e001 marie manipal f 960000

e101 sammy udupi m 710000 e001 Accounts

e102 mark scott manipal m 740000 e001 Sales

e111 aana uchila f 430000 e101 Accounts

e112 rocky kundapur m 150000 e101 Accounts

e113 mahesh mulki m 360000 e102 Sales

e114 ankitha udupi f 350000 e102 Sales

e103 allen manglore m 920000 e001 IT

e115 amrutha barkur f 700000 e103 IT

e116 sonali mulki f 450000 e103 IT

SSN ENAME ADDRESS G SALARY SUPER DNAME

---------- ---------- ---------- - ---------- ----- ----------

e117 anush kaup m 650000 e103 IT


e118 chaya brahmavara f 610000 e103 IT

e119 ram udupi m 560000 e103 IT

e120 ramya udupi f 450000 e103 IT

15 rows selected.

SQL> select *from dloc;

DNO DLOC

---------- --------------------

d1 manipal

d2 udupi

SQL> insert into dloc values('&DNO','&DLOC');

Enter value for dno: d3

Enter value for dloc: manglore

old 1: insert into dloc values('&DNO','&DLOC')

new 1: insert into dloc values('d3','manglore')

1 row created.

SQL> select *from dloc;

DNO DLOC

---------- --------------------

d1 manipal

d2 udupi
d3 manglore

Query:

1)SQL> select ssn,ename,pno,'worker' from(select ssn from emp minus select mgrssn from dept)natural join
emp natural join workson where ename like'%scott';

SSN ENAME PNO 'WORKE

---------- ---------- ---------- ------

e121 je scott P1 worker

SQL> select ssn,pno,pname,'manager' from dept natural join projectt join emp on(ssn=mgrssn)where ename
like'%scott';

SSN PNO PNAME 'MANAGE

---------- ---------- -------------------- -------

e102 P3 webdeveloper manager

SQL> select ssn,ename,pno,'worker' from(select ssn from emp minus select mgrssn from dept)natural join
emp natural join workson where ename like'%scott' union select ssn,pno,pname,'manager' from dept natural
join projectt join emp on(ssn=mgrssn)where ename like'%scott';

SSN ENAME PNO 'WORKER

---------- ---------- -------------------- -------

e102 P3 webdeveloper manager

e121 je scott P1 worker

or

SQL> select ssn,ename,pno, 'manager' from dept natural join projectt join emp on(ssn=mgrssn)where ename
like'%scott';
SSN ENAME PNO 'MANAGE

---------- ---------- ---------- -------

e102 mark scott P3 manager

4)SQL> select ssn,ename,pno,'worker' from(select ssn from emp minus select mgrssn from dept)natural join
emp natural join workson where ename like'%scott' union select ssn,ename,pno,'manager' from dept natural
join projectt join emp on(ssn=mgrssn)where ename like'%scott';

SSN ENAME PNO 'WORKER

---------- ---------- -- -------- -------

e102 mark scott P3 manager

e121 je scott P1 worker

2)SQL>select SSN,SALARY+(SALARY*0.10)"raised"from emp natural join workson natural join projectt where
PNAME='IOT';

SSN raised

---------- ----------

e116 495000

e118 671000

e119 616000

e120 495000

3)select sum(SALARY)"sum",min(SALARY)"min",max(SALARY)"max",avg(SALARY)"average" from emp where


DNAME='Accounts';

sum min max average


---------- ---------- ---------- ----------

1290000 150000 710000 430000

4) SQL> select ename from emp where exists(select * from(select pno from projectt where dno='d5')natural
join workson "A" where emp.ssn=A.ssn);

ENAME

----------

sonali

ram

ramya

chaya

je scott

anush

6 rows selected.

5)select dname,count(*),sum(salary) from emp group by dname having count(*)>5 and sum(salary)>600000;

DNAME COUNT(*) SUM(SALARY)

---------- --------- ---- -------

IT 8 49890000

Pl/sql:

SET SERVEROUTPUT ON
declare

cursor emp_cur is select ssn,ename,salary from emp;

eno emp.ssn%type;

da number(10,2);

hra number(10,2);

net number(10,2);

tax number(10,2);

name emp.ename%type;

basic emp.salary%type;

begin

open emp_cur;

loop

fetch emp_cur into eno,name,basic;

exit when emp_cur%NOTFOUND;

da:=basic*0.12;

hra:=basic*0.10;

tax:=basic*0.10;

net:=basic+da+hra-tax;

DBMS_OUTPUT.PUT_LINE('ssn='||eno||' '||'empname='||name||' '||'Salary='||basic||' '||'da='||da||'


'||'hra='||hra||' '||'net='||net||' '||'tax='||tax);

end loop;

close emp_cur;

end;

SQL> @d:emp.sql

ssn=e121 empname=je scott Salary=650000 da=78000 hra=65000 net=728000 tax=65000


ssn=e001 empname=marie Salary=960000 da=115200 hra=96000 net=1075200 tax=96000

ssn=e101 empname=sammy Salary=710000 da=85200 hra=71000 net=795200 tax=71000

ssn=e102 empname=mark scott Salary=740000 da=88800 hra=74000 net=828800

tax=74000

ssn=e111 empname=aana Salary=430000 da=51600 hra=43000 net=481600 tax=43000

ssn=e112 empname=rocky Salary=150000 da=18000 hra=15000 net=168000 tax=15000

ssn=e113 empname=mahesh Salary=360000 da=43200 hra=36000 net=403200 tax=36000

ssn=e114 empname=ankitha Salary=350000 da=42000 hra=35000 net=392000 tax=35000

ssn=e103 empname=allen Salary=920000 da=110400 hra=92000 net=1030400 tax=92000

ssn=e115 empname=amrutha Salary=700000 da=84000 hra=70000 net=784000 tax=70000

ssn=e116 empname=sonali Salary=450000 da=54000 hra=45000 net=504000 tax=45000

ssn=e117 empname=anush Salary=650000 da=78000 hra=65000 net=728000 tax=65000

ssn=e118 empname=chaya Salary=610000 da=73200 hra=61000 net=683200 tax=61000

ssn=e119 empname=ram Salary=560000 da=67200 hra=56000 net=627200 tax=56000

ssn=e120 empname=ramya Salary=450000 da=54000 hra=45000 net=504000 tax=45000

PL/SQL procedure successfully completed.

2) SET SERVEROUTPUT ON

declare

Cursor emp_cur is select w.ename,m.ename from emp w left join emp m on(w.superssn=m.ssn);

Name varchar(10);

SuperName varchar(10);

begin

open emp_cur;

loop

fetch emp_cur into Name,SuperName;


exit when emp_cur%NOTFOUND;

if(SuperName!='')then

DBMS_OUTPUT.PUT_LINE('Name='||Name||' '||'SuperName='||SuperName);

else

SuperName:='SuperBoss';

DBMS_OUTPUT.PUT_LINE('Name='||Name||' '||'SuperName='||SuperName);

end if;

end loop;

close emp_cur;

end;

SQL> @ d:emp1.sql

Name=allen SuperName=SuperBoss

Name=mark scott SuperName=SuperBoss

Name=sammy SuperName=SuperBoss

Name=rocky SuperName=SuperBoss

Name=aana SuperName=SuperBoss

Name=ankitha SuperName=SuperBoss

Name=mahesh SuperName=SuperBoss

Name=ramya SuperName=SuperBoss

Name=ram SuperName=SuperBoss

Name=chaya SuperName=SuperBoss

Name=anush SuperName=SuperBoss

Name=sonali SuperName=SuperBoss

Name=amrutha SuperName=SuperBoss

Name=je scott SuperName=SuperBoss

Name=marie SuperName=SuperBoss
PL/SQL procedure successfully completed.

3) create table managerinfo

(managerid number(3),

managername varchar(10),

deptid number(3),

deptname varchar(10),

startdate date,

enddate date);

sql>@:manager.sql

table created.

SET SERVEROUTPUT ON

create or replace trigger trig before update of mgrssn on dept

FOR EACH ROW

declare

nameC varchar2(10);

begin

select ename into nameC from emp where ssn=:old.mgrssn;

Insert into managerinfo values(:old.mgrssn,nameC,:old.dno,:old.dname,:old.mgrstartdate,sysdate-1);

end;

/
Sql>@ d:trigger.sql

Trigger created.

sql>select *from managerinfo;

managerid manq.name dept deptname startdate end date

e103 allwen d5 it 12-aug-01 26-jun-22


2 . Consider the college database.

STUDENT CLASS
Name Constraint Name Constraint
USN Primary Key, must begin with M USN Part of primary key, Foreign Key
SName Not Null references Student
Address Not Null SSID Must be in ISem_MSc,
Phone Unique IISem_MSc, IIISem_MSc,
Gender Must be in(‘F’, ‘M’) IVSem_MSc

SUBJECT
Name Constraint IAMARKS
SubCode Primary Key Name Constraint
Title Not Null USN Foreign Key references
SSID Must be in ISem_MSc, Student
IISem_MSc, IIISem_MSc, SSID Must be in ISem_MSc,
IVSem_MSc IISem_MSc, IIISem_MSc,
Credits Not Null IVSem_MSc
SubCode Foreign Key references Subject
Test1 Not Null must be <=30
Test2 Not Null must be <=30
Test3 Not Null must be <=30
FinalA Not Null must be <=30

Write SQL queries to


1. List all the student details studying in fourth semester.
2. Compute the total number of male and female students in each semester.
3. Create a view of Test1 marks of student USN ’M2020-101’ in all subjects.
4. Calculate the FinalIA (average of best two test marks) and update the corresponding table for all
students. (Trigger)
5. Categorize students based on the following criterion:
If FinalIA = 17 to 20 then CAT = ‘Outstanding’
If FinalIA = 12 to 16 then CAT = ‘Average’
If FinalIA< 12 then CAT = ‘Weak’
Give these details only for III semester MSc students.

PL/SQL
1. Write the PL/SQL code to list all the subjects of a particular course.
2. Write a procedure to return total number of male and female students.
3. Write a trigger to insert student information such as USN, name, marks into new table
Average_Students who got less marks (<17) in FinalA.

SQL> create table student

2 (USN varchar(20)primary key constraint usn_pk check(USN like('M%')),


3 SName varchar(20)not null,

4 Address varchar(20)not null,

5 Phone number(10)constraint phone_uk unique,

6 Gender char(1)constraint gender_stu check(Gender in('F','M')));

Table created.

SQL> create table class

2 (USN varchar(20)constraint usn_fk references student,

3 SSID varchar(10)constraint ssid check(SSID in('1Sem_MSc','2Sem_MSc','3Sem_MSc','4Sem_MSc')),

4 primary key(USN,SSID));

Table created.

SQL> create table subject

2 (SubCode varchar(10)primary key,

3 Title varchar(10)not null,

4 SSID varchar(10)constraint ssid_sub check(SSID in('1Sem_MSc','2Sem_MSc','3Sem_MSc','4Sem_MSc')),

5 Credits varchar(10)not null);

Table created.

SQL> create table iamarks

2 (USN varchar(20),

3 SSID varchar(10),

4 SubCode varchar(10)constraint subcode references subject,

5 Test1 number(5)not null constraint test1 check(Test1<=30),

6 Test2 number(5)not null constraint test2 check(Test2<=30),

7 Test3 number(5)not null constraint test3 check(Test3<=30),

8 finala number(10)not null check(finala<=30),

9 primary key(USN,SSID,SubCode),
10 foreign key(USN,SSID)references class);

Table created.

SQL> insert into student values('&USN','&SName','&Address','&Phone','&Gender');

Enter value for usn: M2020-100

Enter value for sname: Amrutha

Enter value for address: barkur

Enter value for phone: 9356573501

Enter value for gender: F

old 1: insert into student values('&USN','&SName','&Address','&Phone','&Gender')

new 1: insert into student values('M2020-100','Amrutha','barkur','9356573501','F')

1 row created.

SQL> select *From student;

USN SNAME ADDRESS PHONE G

-------------------- -------------------- -------------------- ---------- -

M2020-100 Amrutha barkur 9356573501 F

M2020-101 chaya brahmavar 9264519043 F

M2020-102 kiran udupi 8723572310 M

M2020-103 ram manipal 8430261897 M

M2020-104 nandini manglore 9734267086 F

M2020-105 Ramya udupi 9836209876 F

M2020-106 Rahul manipal 8734520913 M

7 rows selected.

SQL> insert into class values('&USN','&SSID');


Enter value for usn: M2020-100

Enter value for ssid: 1Sem_MSc

old 1: insert into class values('&USN','&SSID')

new 1: insert into class values('M2020-100','1Sem_MSc')

1 row created.

SQL> select *from class;

USN SSID

-------------------- ----------

M2020-100 1Sem_MSc

M2020-101 2Sem_MSc

M2020-102 3Sem_MSc

M2020-103 4Sem_MSc

M2020-104 4Sem_MSc

M2020-105 4Sem_MSc

M2020-106 2Sem_MSc

7 rows selected.

SQL> insert into subject values('&SubCode','&Title','&SSID','&Credits');

Enter value for subcode: MSCCSH103

Enter value for title: CG

Enter value for ssid: 1Sem_MSc

Enter value for credits: 8

old 1: insert into subject values('&SubCode','&Title','&SSID','&Credits')

new 1: insert into subject values('MSCCSH103','CG','1Sem_MSc','8')


1 row created.

SQL> select *from subject;

SUBCODE TITLE SSID CREDITS

---------- ---------- ---------- ----------

MSCCSH103 CG 1Sem_MSc 8

MSCCSD104 DBMS 2Sem_MSc 7

MSCCSS105 DS 3Sem_MSc 8

MSCCST108 IOT 4Sem_MSc 8

SQL> insert into iamarks values('&USN','&SSID','&SubCode','&Test1','&Test2','&Test3','&finala');

Enter value for usn: M2020-100

Enter value for ssid: 1Sem_MSc

Enter value for subcode: MSCCSH103

Enter value for test1: 23

Enter value for test2: 21

Enter value for test3: 21

Enter value for finala: 1

old 1: insert into iamarks values('&USN','&SSID','&SubCode','&Test1','&Test2','&Test3','&finala')

new 1: insert into iamarks values('M2020-100','1Sem_MSc','MSCCSH103','23','21','21','1')

1 row created.

SQL> select *from iamarks;

USN SSID SUBCODE TEST1 TEST2 TEST3

-------------------- ---------- ---------- ---------- ---------- ----------

FINALA

----------
M2020-100 1Sem_MSc MSCCSH103 23 21 21

M2020-101 2Sem_MSc MSCCSD104 28 24 25

M2020-102 3Sem_MSc MSCCSS105 27 25 25

M2020-104 4Sem_MSc MSCCST108 23 29 27

SQL> insert into iamarks values('&USN','&SSID','&SubCode','&Test1','&Test2','&Test3','&finala');

Enter value for usn: M2020-100

Enter value for ssid: 1Sem_MSc

Enter value for subcode: MSCCSH103

Enter value for test1: 23

Enter value for test2: 26

Enter value for test3: 25

Enter value for finala: 1

old 1: insert into iamarks values('&USN','&SSID','&SubCode','&Test1','&Test2','&Test3','&finala')

new 1: insert into iamarks values('M2020-100','1Sem_MSc','MSCCSH103','23','26','25','1')

1 row created.

SQL> select *from subject;

SUBCODE TITLE SSID CREDITS

---------- ---------- ---------- ----------

MSCCSH103 CG 1Sem_MSc 8
MSCCSD104 DBMS 2Sem_MSc 7

MSCCSS105 DS 3Sem_MSc 8

MSCCST108 IOT 4Sem_MSc 8

MSCCSD101 ADS 2Sem_MSc 6

MSCCSD102 AOS 2Sem_MSc 7

6 rows selected.

SQL> select *from class;

USN SSID

-------------------- ----------

M2020-100 1Sem_MSc

M2020-101 2Sem_MSc

M2020-102 2Sem_MSc

M2020-102 3Sem_MSc

M2020-103 4Sem_MSc

M2020-104 2Sem_MSc

M2020-104 4Sem_MSc

M2020-105 4Sem_MSc

M2020-106 2Sem_MSc

9 rows selected.

SQL> select *from iamarks;

USN SSID SUBCODE TEST1 TEST2 TEST3

-------------------- ---------- ---------- ---------- ---------- ----------

FINALA

----------

M2020-100 1Sem_MSc MSCCSH103 23 26 25


1

M2020-101 2Sem_MSc MSCCSD104 23 21 26

M2020-102 3Sem_MSc MSCCSS105 24 2 5

M2020-103 4Sem_MSc MSCCSS105 23 2 23

M2020-104 2Sem_MSc MSCCSD101 23 24 26

QUERY

1> SQL> select *from student natural join class where ssid='4Sem_MSc';

USN SNAME ADDRESS PHONE G

-------------------- -------------------- -------------------- ---------- -

SSID

----------

M2020-103 ram manipal 8430261897 M

4Sem_MSc

M2020-104 nandini manglore 9734267086 F

4Sem_MSc

M2020-105 Ramya udupi 9836209876 F

4Sem_MSc
2>SQL> select ssid,gender,count(*)from student natural join class group by ssid,gender order by ssid;

SSID G COUNT(*)

---------- - ----------

1Sem_MSc F 1

2Sem_MSc F 2

2Sem_MSc M 2

3Sem_MSc M 1

4Sem_MSc F 2

4Sem_MSc M 1

6 rows selected.

3> SQL> create view v as select subcode,test1,test2,test3,finala from iamarks where usn='M2020-101';

View created.

SQL> select *from iamarks;

USN SSID SUBCODE TEST1 TEST2 TEST3

-------------------- ---------- ---------- ---------- ---------- ----------

FINALA

----------

M2020-100 1Sem_MSc MSCCSH103 23 26 25

M2020-101 2Sem_MSc MSCCSD104 23 21 26

1
M2020-102 3Sem_MSc MSCCSS105 24 2 5

M2020-103 4Sem_MSc MSCCSS105 23 2 23

M2020-104 2Sem_MSc MSCCSD101 23 24 26

4> SQL> update iamarks set finala=(case when test1>=test2 and test3>=test2 then (test1+test3)/2 when
test2>=test3 and test1>=test3 then (test2+test1)/2 when test2>=test1 and test3>=test1 then(test2+test3)/2
end)where USN in iamarks.usn;

5 rows updated.

SQL> select *from iamarks;

USN SSID SUBCODE TEST1 TEST2 TEST3

-------------------- ---------- ---------- ---------- ---------- ----------

FINALA

----------

M2020-100 1Sem_MSc MSCCSH103 23 26 25

26

M2020-101 2Sem_MSc MSCCSD104 23 21 26

25

M2020-102 3Sem_MSc MSCCSS105 24 2 5

15

SQL> select *from iamarks;

USN SSID SUBCODE TEST1 TEST2 TEST3


-------------------- ---------- ---------- ---------- ---------- ----------

FINALA

----------

M2020-103 4Sem_MSc MSCCSS105 23 2 23

23

M2020-104 2Sem_MSc MSCCSD101 23 24 26

25

5> SQL> select usn,finala,case when finala>17 and finala<=30 then 'outstanding' when finala>12 and
finala<=17 then'average' else 'weak' end as cat from iamarks where ssid='3Sem_MSc';

USN FINALA CAT

-------------------- ---------- -----------

M2020-102 15 average

PLSQL

1) set serveroutput on

declare

cursor sub_cur is select subcode,title,ssid from subject order by ssid;

sc subject.subcode%type;

ttl subject.title%type;

course subject.ssid%type;

begin

dbms_output.put_line('course subcode subject');

open sub_cur;

loop

fetch sub_cur into sc,ttl,course;

exit when sub_cur%notfound;

dbms_output.put_line(course||' '||SC||' '||ttl);


end loop;

close sub_cur;

end;

SQL> @d:subject.sql

course subcode subject

1Sem_MSc MSCCSH103 CG

2Sem_MSc MSCCSD104 DBMS

2Sem_MSc MSCCSD102 AOS

2Sem_MSc MSCCSD101 ADS

3Sem_MSc MSCCSS105 DS

4Sem_MSc MSCCST108 IOT

PL/SQL procedure successfully completed.

2) set serveroutput on

declare

cursor gen_cur is select gender from student;

g student.gender%type;

fcount number(3);

mcount number(3);

begin

mcount:=0;

fcount:=0;

open gen_cur;

loop

fetch gen_cur into g;

exit when gen_cur%notfound;

if(g='M')then
mcount:=mcount+1;

else

fcount:=fcount+1;

end if;

end loop;

dbms_output.put_line('total number of male students='||mcount);

dbms_output.put_line('total number of female students='||fcount);

close gen_cur;

end;

Output:

SQL> @d:gender.sql

total number of male students=3

total number of female students=4

PL/SQL procedure successfully completed.

3) create table averagestd(USN varchar(10),

name varchar(10),

test1 number(3),

test2 number(3),

test3 number(3),

finala number(3));

trigger:

set serveroutput on

create or replace trigger trig_sub after update of finala on iamarks for each row

declare

nameV varchar(10);
begin

if(:new.finala<17)then

select sname into nameV from student where usn=:old.usn;

insert into averagestd values(:new.usn,nameV,:new.test1,:new.test2,:new.test3,:new.finala);

end if;

end;

SQL> update iamarks set finala=(case when test1>=test2 and test3>=test2 then (test1+test3)/2 when
test2>=test3 and test1>=test3 then (test2+test1)/2 when test2>=test1 and test3>=test1 then(test2+test3)/2
end)where USN in iamarks.usn;

5 rows updated.

SQL> select *from averagestd;

USN NAME TEST1 TEST2 TEST3 FINALA

---------- ---------- ---------- ---------- ---------- ----------

M2020-102 kiran 24 2 5 15
3. Consider the schema for Movie

ACTOR Director
Name Constraint Name Constraint
Act_Id Primary key Dir_Id Primary key
Act_Name Not Null Dir_Name Not Null
Act_Gender ‘M’ or ‘F’ Dir_Phone unique

MOVIES Movie_Cast
Name Constraint Name Constraint
Mov_Id Primary key Act_Id Foreign key references
Mov_Title Not Null Actor, Part of Primary Key
Mov_Year Not Null Mov_Id Foreign key references
Mov_Lang Not Null Movie, Part of Primary
Dir_Id Foreign Key references Key
Director Role Must be in HRO, HRN,
SPCHR or CMDN
RATING
Name Constraint
Mov_Id Primary Key, Foreign Key references Movie
Rev_Stars Must be in 1, 2, 3, 4, 5

Write SQL queries to


1. List the titles of all movies directed by ‘Suraj’ and ‘Vinay’ in which Ravitheja acted as hero.
2. Find the movie name and actor name where actors acted in more than 3 movies.
3. List all actors who acted in a movie before 2000 and also in a movie after 2015
4. Find the title of movies and number of stars for each movie received and Sort the result by movie title.
5. Update rating of all movies directed by ‘Shreesha’ to 5.

PL/SQL
1. Write procedure to return total number of movies acted as hero/heroine and total number of movies in
supporting character by an actor/actress. (send the actor id through application program)
2. Write the PL/SQL program to display all cast names and director name of a movie.
3. Write PL/SQL program to input any two actor names display all movie names in which they acted
together. If no movies then raise user defined exception and handle it.

SQL> create table Actor(

2 act_id varchar(10),

3 act_name varchar(10)not null,

4 act_gender char(1));
Table created.

SQL> alter table Actor add constraint act_pk primary key(act_id);

Table altered.

SQL> create table Director(

2 dir_id varchar(10)constraint dir_pk primary key,

3 dir_name varchar(10)not null,

4 dir_phone number(10)constraint phone_no unique);

Table created.

SQL> create table movies(

2 mov_id varchar(10)constraint mov_id primary key,

3 mov_title varchar(10)not null,

4 mov_year number(4)not null,

5 dir_id varchar(10)constraint dir_fk references Director);

Table created.

SQL> alter table movies add mov_lang varchar(10)not null;

Table altered.

SQL> alter table Actor drop constraint SYS_C00191465;

Table altered.

SQL> alter table Actor add constraint gen_cur check(act_gender in('F','M'));

Table altered.
SQL> create table movie_cast(

2 act_id varchar(10)constraint act references Actor,

3 mov_id varchar(10)constraint movie references movies,

4 role varchar(10)constraint role check(role in('HRO','HRN','SPCHR','CMDN')),

5 primary key(act_id,mov_id));

Table created.

SQL> create table ratings(

2 mov_id varchar(10)primary key references movies,

3 rev_stars number(4)constraint rev check(rev_stars in('1','2','3','4','5')));

Table created.

SQL> insert into Actor values('&act_id','&act_name','&act_gender');

Enter value for act_id: a776

Enter value for act_name: radika

Enter value for act_gender: F

old 1: insert into Actor values('&act_id','&act_name','&act_gender')

new 1: insert into Actor values('a776','radika','F')

1 row created.

SQL> select *from Actor;

ACT_ID ACT_NAME A

---------- ---------- -

a771 yash M

a772 sudeep M

a773 shanvi F

a774 priyamani F
a775 puneeth M

a776 radika F

a777 allu arjun M

a778 siddarth M

8 rows selected.

SQL> insert into Director values('&dir_id','&dir_name','&dir_phone');

Enter value for dir_id: d13

Enter value for dir_name: prashaanth

Enter value for dir_phone: 9302765532

old 1: insert into Director values('&dir_id','&dir_name','&dir_phone')

new 1: insert into Director values('d13','prashaanth','9302765532')

1 row created.

SQL> select *from Director;

DIR_ID DIR_NAME DIR_PHONE

---------- ---------- ----------

d11 anup 9270175091

d12 pavan 894206927

d13 prashaanth 9302765532

SQL> insert into movies values('&mov_id','&mov_title','&mov_year','&dir_id','&mov_lang');

Enter value for mov_id: m6

Enter value for mov_title: hebbuli

Enter value for mov_year: 2018

Enter value for dir_id: d11

Enter value for mov_lang: kannada

old 1: insert into movies values('&mov_id','&mov_title','&mov_year','&dir_id','&mov_lang')


new 1: insert into movies values('m6','hebbuli','2018','d11','kannada')

1 row created.

SQL> select *from movies;

MOV_ID MOV_TITLE MOV_YEAR DIR_ID MOV_LANG

---------- ---------- ---------- ---------- ----------

m1 drama 2005 d13 kannada

m2 tharak 2001 d12 kannada

m3 ram 1998 d11 kannada

m4 aarya 2001 d12 telugu

m5 my friend 2015 d13 telugu

m6 hebbuli 2018 d11 kannada

6 rows selected.

SQL> insert into movie_cast values('&act_id','&mov_id','&role');

Enter value for act_id: a772

Enter value for mov_id: m3

Enter value for role: CMDN

old 1: insert into movie_cast values('&act_id','&mov_id','&role')

new 1: insert into movie_cast values('a772','m3','CMDN')

1 row created.

SQL> select *from movie_cast;

ACT_ID MOV_ID ROLE

---------- ---------- ----------


a771 m1 HRO

a776 m1 HRN

a772 m6 HRO

a773 m6 HRN

a773 m3 SPCHR

a774 m3 HRN

a775 m3 HRO

a774 m4 HRN

a777 m4 HRO

a778 m5 HRO

a774 m5 HRN

ACT_ID MOV_ID ROLE

---------- ---------- ----------

a773 m2 HRN

a772 m2 HRO

a778 m4 SPCHR

a772 m3 CMDN

15 rows selected.

SQL> insert into ratings values('&mov_id','&rev_stars');

Enter value for mov_id: m6

Enter value for rev_stars: 3

old 1: insert into ratings values('&mov_id','&rev_stars')

new 1: insert into ratings values('m6','3')

1 row created.
SQL> select *from ratings;

MOV_ID REV_STARS

---------- ----------

m1 4

m2 5

m3 3

m4 5

m5 4

m6 3

6 rows selected.

Query

1> SQL> select mov_title,dir_name from movies natural join actor natural join director natural join movie_cast
where act_name='yash' and role='HRO' and(dir_name='anup'or dir_name='prashaanth');

MOV_TITLE DIR_NAME

---------- ----------

drama prashaanth

googly anup

2) SQL> select act_name,mov_title from actor natural join movie_cast natural join movies where act_id
in(select act_id from movie_cast having count(act_id)>=3 group by act_id);

ACT_NAME MOV_TITLE

---------- ----------

yash drama

yash tharak

yash googly

sudeep drama
sudeep ram

sudeep hebbuli

priyamani ram

priyamani aarya

priyamani my friend

9 rows selected.

3) SQL> select act_id,act_name,'act_name2000' from actor where act_id in(select distinct act_id from
movie_cast where mov_id in(select mov_id from movies where mov_year<=2000))union select
act_id,act_name,'act_name2015' from actor where act_id in(select distinct act_id from movie_cast where
mov_id in(select mov_id from movies where mov_year>=2015));

ACT_ID ACT_NAME 'ACT_NAME200

---------- ---------- ------------

a772 sudeep act_name2000

a772 sudeep act_name2015

a773 shanvi act_name2000

a773 shanvi act_name2015

a774 priyamani act_name2000

a774 priyamani act_name2015

a775 puneeth act_name2000

a778 siddarth act_name2015

8 rows selected.

4) SQL> select mov_title,rev_stars from movies natural join ratings order by mov_title;

MOV_TITLE REV_STARS

---------- ----------

aarya 5

drama 4
hebbuli 3

my friend 4

ram 3

tharak 5

6 rows selected.

5) SQL> update ratings set rev_stars=5 where mov_id in(select mov_id from movies where dir_id=(select
dir_id from director where dir_name='anup'));

2 rows updated.

SQL> Select *from ratings;

MOV_ID REV_STARS

---------- ----------

m1 4

m2 5

m3 5

m4 5

m5 4

m6 5

6 rows selected.

Pl/sql

1)set serveroutput on

create or replace procedure pro(A1 in varchar,A2 in varchar,A3 out varchar)is countv number(3);

begin

if(A2=1)then

Select count(*) into countv from movie_cast where act_id=A1 and (role='HRO' or role='HRN');
A3:=countv;

else

select count(*)into countv from movie_cast where act_id=A1 and (role='SPCHR' or role='CMDN');

A3:=countv;

end if;

end;

Ed d:Movie1.sql

set serveroutput on

declare

actv varchar(5);

exe number(5);

actn varchar(10);

hron varchar(10);

spch varchar(10);

begin

actv:=&actv;

select count(*)into exe from actor where act_id=actv;

if(exe>0)then

select act_name into actn from actor where act_id=actv;

dbms_output.put_line('actor name is'||actn);

pro(actv,1,hron);

pro(actv,2,spch);

dbms_output.put_line('acted as hero or heroine in'||hron||'movies');

dbms_output.put_line('acted as spch/cmdn in'||spch||'movies');

else

dbms_output.put_line('no actor found');

end if;
end;

Enter value for actv: 'a773'

old 8: actv:=&actv;

new 8: actv:='a773';

actor name isshanvi

acted as hero or heroine in1movies

acted as spch/cmdn in1movies

PL/SQL procedure successfully completed.

2)set serveroutput on

declare

cursor c is select mov_id from movies;

cursor c1 is select act_id,mov_id,role from movie_cast;

movidv varchar(4);

actidv varchar(4);

movidv2 varchar(4);

movnv varchar(10);

dirv varchar(10);

actnv varchar(10);

rolev3 varchar(10);

begin

open c;

loop

fetch c into movidv;

exit when c%NOTFOUND;

dbms_output.put_line('----------------');

dbms_output.put_line('Movie id is'||movidv);
select mov_title into movnv from movies where mov_id=movidv;

dbms_output.put_line('moviename is'||movnv);

select dir_name into dirv from director where dir_id=(select dir_id from movies where mov_id=movidv);

dbms_output.put_line('director is'||dirv);

open c1;

loop

fetch c1 into actidv,movidv2,rolev3;

exit when c1%NOTFOUND;

if(movidv2=movidv)then

select act_name into actnv from actor where act_id=actidv;

dbms_output.put_line('actor id is'||actnv||'role is'||rolev3);

end if;

end loop;

close c1;

dbms_output.put_line('----------------');

end loop;

close c;

end;

SQL> ed d:director.sql

SQL> @ d:director.sql

----------------

Movie id is m1

Movie name is drama

director Is prashaanth

actor id is yashrole isHRO

actor id is radikarole isHRN

actor id is sudeeprole is
----------------

----------------

Movie id is m2

Movie name is tharak

director is pavan

actor id is yash role isHRO

actor id is radika role Is HRN

----------------

----------------

Movie id is m3

Movie name is ram

director is anup

actor id is sudeep role is CMDN

actor id is shanvi role is SPCHR

actor id is priyamani role is HRN

actor id is puneeth role isHRO

----------------

----------------

Movie id ism4

Movie name is aarya

director is pavan

actor id is priyamani role is HRN

actor id is allu arjun role is HRO

----------------

----------------

Movie id ism5

Movie name is my friend

director isprashaanth

actor id issiddarthrole isHRO


actor id ispriyamanirole isHRN

----------------

----------------

Movie id ism6

moviename ishebbuli

director isanup

actor id issudeeprole is

actor id isshanvirole isHRN

----------------

----------------

Movie id ism7

moviename isgoogly

director isanup

actor id isyashrole isHRO

----------------

PL/SQL procedure successfully completed.

3) set serveroutput on

declare

exp1 exception;

exist number(2);

act1 varchar2(20);

act2 varchar2(20);

id1 varchar2(10);

id2 varchar2(10);

titv varchar2(20);

f number(1);

begin

f:=0;
act1:=&act1;

act2:=&act2;

select count(*) into exist from actor where act_name=act1;

if(exist>0) then

select act_id into id1 from actor where act_name=act1;

select count(*) into exist from actor where act_name=act2;

if(exist>0) then

select act_id into id2 from actor where act_name=act2;

dbms_output.put_line('Movie acted together are');

for c in(select mov_title into titv from movies where mov_id in(select mov_id from movie_cast where
act_id=id1

intersect

select mov_id from movie_cast where act_id=id2))

loop

f:=1;

titv:=c.mov_title;

dbms_output.put_line(titv);

end loop;

if(f=0) then

raise exp1;

end if;

else

dbms_output.put_line('Actor2 does not exist');

end if;

else

dbms_output.put_line('Actor1 does not exist');

end if;

exception

when exp1 then


dbms_output.put_line('---None---');

end;

SQL> @ d:exception.sql

Enter value for act1: 'yash'

old 12: act1:=&act1;

new 12: act1:='yash';

Enter value for act2: 'radika'

old 13: act2:=&act2;

new 13: act2:='radika';

Movie acted together are

drama

tharak

PL/SQL procedure successfully completed.


4. Consider the following schema for Order Database:

SALESMAN
Name Type Constraint
S_ID Varchar(5) must start from S, Primary Key
S_Name Varchar(20) Not Null
City Varchar(20) Not Null

CUSTOMER
Name Type Constraint
C_ID Varchar(5) must start from C, Primary Key
Cust_Name Varchar(20) Not Null
City Varchar(20) Not Null

ORDERS
Name Type Constraint
O_NO Varchar(5) must start with O, Primary Key
C_ID Varchar(5) Not Null, Foreign Key refers to Customer
S_ID Varchar(5) Not Null, Foreign Key refers to Salesman
Purchase_Am Number(15, 2) Not Null
t
Grade Number(3) Not Null, Grade must be in(100, 200, 300, 400)
Commission Number(10, 2) must be >10% default 10
Order_date date

S_COMMISSION
Name Type Constraint
S_ID Varchar(5) Foreign Key refers to salesman
Month Varchar(10) Not Null
Year Number(4) Not Null
Commission Number(10, 2) Default 1000

Note: Give names to constraints

Write SQL queries to


1. Count the salesmen with grades above Bangalore’s sales men average.
2. Find the name and numbers of all salesmen who had more than one customer.
3. List all salesmen and indicate those who have and don’t have customers in their cities.
4. Create a view that finds the salesman who has the customer with the highest order of a day.
5. Demonstrate the DELETE operation by removing salesman with id 1000. All his orders must also be deleted.
(Then RollBack the deleted row).

Write PL/SQL program


1. To display information about top three sales man having highest total grades.
2. To calculate the monthly commission of a salesman based on given month and year.
3. To create trigger to fire when there is an insert operation on orders table; record the commission
information in S_Comission.
(Note: Comission is 4% of the each Purchase amount)
4. To create a procedure to calculate total purchase of a customer in a particular month and year. Handle
the exception if the customer id is not found.

SQL> create table salesman(

2 sid varchar(5)primary key constraint name check(sid like('S%')),

3 sname varchar(20)constraint sname not null,

4 city varchar(20)not null);

Table created.

SQL> create table customer(

2 cid varchar(5)primary key constraint cid check(cid like('C%')),

3 cust_name varchar(20)constraint cust_name not null,

4 city varchar(20)not null);

Table created.

SQL> create table orders(

2 ono varchar(5)primary key constraint ono check(ono like('O%')),

3 cid varchar(5)not null constraint cid_orders references customer,

4 sid varchar(5)not null constraint sid_orders references salesman,

5 purchase_amt number(15,2)not null,

6 grade number(3)not null constraint grade check(grade in(100,200,300,400)),

7 commission number(10,2)default 10 constraint commission check(commission>0.10),

8 order_date date);

Table created.

SQL> alter table orders drop column commission;


Table altered.

SQL> alter table orders add commission number(10,2)default 0.10 constraint cmc check(commission>=0.10);

Table altered.

SQL> select *from orders;

ONO CID SID PURCHASE_AMT GRADE ORDER_DAT COMMISSION

----- ----- ----- ------------ ---------- --------- ----------

O1 C101 S101 2000 200 12-FEB-22 .1

O2 C103 S101 2000 200 12-MAY-22 .1

O3 C102 S102 2500 300 12-JUN-22 .1

O4 C104 S102 200 400 09-JAN-22 .1

O5 C105 S103 1300 200 30-AUG-22 .1

O6 C106 S102 1400 100 13-APR-22 .1

O7 C107 S103 3400 200 18-SEP-22 .1

O8 C108 S104 1280 300 14-OCT-22 .1

O9 C109 S104 3210 300 20-DEC-22 .1

9 rows selected.

SQL> create table s_commission(

sid varchar(5)constraint sid_com references salesman,

month varchar(10)not null,

year number(4)not null,

commission number(10,2)default 1000);


Table created.

SQL> insert into salesman values('S104','kiran','udupi');

1 row created.

SQL> select *from salesman;

SID SNAME CITY

----- -------------------- --------------------

S101 anush banglore

S102 hari manglore

S103 suresh manipal

S104 kiran udupi

SQL> insert into customer values('C109','arun','udupi');

1 row created.

SQL> select *from customer;

CID CUST_NAME CITY

----- -------------------- --------------------

C101 amrutha udupi

C102 navya banglore

C103 swati manglore

C104 geeta manipal


C105 ganesh manipal

C106 sachin manglore

C107 nithesh banglore

C108 akshay udupi

C109 arun udupi

9 rows selected.

SQL> insert into orders(ono,cid,sid,purchase_amt,grade,order_date)values('O9','C109','S104',3210,300,'20-


dec-22');

1 row created.

SQL> select *from orders;

ONO CID SID PURCHASE_AMT GRADE COMMISSION ORDER_DAT

----- ----- ----- ------------ ---------- ---------- ---------

O1 C101 S101 2000 200 10 12-FEB-22

O2 C103 S101 2000 200 10 12-MAY-22

O3 C102 S102 2500 300 10 12-JUN-22

O4 C104 S102 200 400 10 09-JAN-22

O5 C105 S103 1300 200 10 30-AUG-22

O6 C106 S102 1400 100 10 13-APR-22

O7 C107 S103 3400 200 10 18-SEP-22

O8 C108 S104 1280 300 10 14-OCT-22

O9 C109 S104 3210 300 10 20-DEC-22


9 rows selected.

Query

1.SQL> select count(distinct sid)from orders natural join salesman where grade>(select avg(grade)

from orders natural join salesman where city='banglore')and city!='banglore';

COUNT(DISTINCTSID)

------------------

2.SQL> select salesman.sname,count(*)from salesman join orders on(salesman.sid=orders.sid)

group by salesman.sname having count(distinct cid)>1;

SNAME COUNT(*)

-------------------- ----------

kiran 2

anush 2

suresh 2

hari 3

3.SQL> select salesman.city,sname,count(cust_name)from salesman left join customer


on(salesman.city=customer.city)group by salesman.city,sname;

CITY SNAME COUNT(CUST_NAME)

-------------------- -------------------- ----------------

manipal suresh 2

banglore anush 2

manglore hari 2

udupi kiran 3
4.SQL> create view salesman_view as select sid,sname from salesman where sid in(select sid from orders
where order_date='30-aug-22' group by sid having count(cid)=(select max(count(cid))from orders where
order_date='30-aug-22'group by(cid)));

View created.

SQL> select *from salesman_view;

SID SNAME

----- --------------------

S103 suresh

5.SQL> alter table orders drop constraint sid_orders;

Table altered.

SQL> alter table orders add constraint sid_fk foreign key(sid) references salesman on delete cascade;

Table altered

SQL> alter table s_commission drop constraint sid_com;

Table altered.

SQL> alter table s_commission add constraint sid_cm foreign key(sid)references salesman on delete cascade;

Table altered.

SQL> select *from salesman;

SID SNAME CITY

----- -------------------- --------------------

S101 anush banglore

S102 hari manglore


S103 suresh manipal

S104 kiran udupi

SQL> delete from salesman where sid='S101';

1 row deleted.

SQL> select *from salesman;

SID SNAME CITY

----- -------------------- --------------------

S102 hari manglore

S103 suresh manipal

S104 kiran udupi

SQL> rollback;

Rollback complete.

SQL> select *from salesman;

SID SNAME CITY

----- -------------------- --------------------

S101 anush banglore

S102 hari manglore

S103 suresh manipal

S104 kiran udupi


Pl/sql

1)set serveroutput on

declare

sm_id salesman.sid%type;

sm_name salesman.sname%type;

sm_city salesman.city%type;

cursor sm_cur is

select sid,sname,city from orders natural join salesman group by sid,sname,city order by sum(grade)desc;

begin

open sm_cur;

dbms_output.put_line('sid sname city');

for i in 1..3

loop

fetch sm_cur into sm_id,sm_name,sm_city;

dbms_output.put_line(sm_id||''||sm_name||''||sm_city);

end loop;

close sm_cur;

end;

SQL> @ d:salesman.sql

sid sname city

S102harimanglore

S104kiranudupi

S103sureshmanipal
PL/SQL procedure successfully completed.

2) set serveroutput on

declare

sm_id salesman.sid%type;

sm_month varchar2(10);

sm_year number(10);

comm number(10,2);

cursor comm_cur is

select sid,month,year,commission from s_commission where month=sm_month and year=sm_year;

begin

sm_month:='&month';

sm_year:='&year';

open comm_cur;

dbms_output.put_line('sid month year commission');

loop

fetch comm_cur into sm_id,sm_month,sm_year,comm;

exit when comm_cur%notfound;

dbms_output.put_line(sm_id||' '||sm_month||' '||sm_year||' '||comm);

end loop;

close comm_cur;

end;

Output:

SQL> @ d:commission;

Enter value for month: DECEMBER


old 9: sm_month:='&month';

new 9: sm_month:='DECEMBER';

Enter value for year: 2022

old 10: sm_year:='&year';

new 10: sm_year:='2022';

sid month year commission

S104 DECEMBER 2022 6000

PL/SQL procedure successfully completed.

3)Procedure:

create or replace procedure s_exists (s_id in varchar, n out number, M IN VARCHAR, Y IN NUMBER)

is

s_id1 varchar(10);

begin

n:=0;

select sid into s_id1 from s_commission where sid=S_ID and month=M and year =Y;

n:=1;

exception

when no_data_found then

dbms_output.put_line('');

end;

create or replace trigger tri_cm1

before insert on orders


for each row

declare

comm number(10,2):=00.00;

s_id varchar(5);

mid varchar(10);

n integer(1):=0;

Y NUMBER(10);

M VARCHAR(20);

begin

comm:=0.4* :new.purchase_amt;

if(comm<1000.00)then

comm:=1000.00;

end if;

if trim(to_CHAR(:NEW.ORDER_DATE,'MONTH'))='JANUARY' then

mid:='JANUARY';

elsif trim(tO_CHAR(:NEW.ORDER_DATE,'MONTH'))='FEBRUARY'

then

mid:='FEBRUARY';

elsif trim(tO_CHAR(:NEW.ORDER_DATE,'MONTH')) ='MARCH' then

mid:='MARCH';

elsif trim(tO_CHAR(:NEW.ORDER_DATE,'MONTH'))='APRIL' then

mid:='APRIL';

elsif trim(tO_CHAR(:NEW.ORDER_DATE,'MONTH'))='MAY' then


mid:='MAY';

elsif trim(tO_CHAR(:NEW.ORDER_DATE,'MONTH'))='JUNE' then

mid:='JUNE';

elsif trim(tO_CHAR(:NEW.ORDER_DATE,'MONTH'))='JULY' then

mid:='JULY';

elsif trim(tO_CHAR(:NEW.ORDER_DATE,'MONTH'))='AUGUST' then

mid:='AUGUST';

elsif trim(tO_CHAR(:NEW.ORDER_DATE,'MONTH'))='SEPTEMBER' then

mid:='SEPTEMBER';

elsif trim(tO_CHAR(:NEW.ORDER_DATE,'MONTH'))='OCTOBER' then

mid:='OCTOBER';

elsif trim(tO_CHAR(:NEW.ORDER_DATE,'MONTH'))='NOVEMBER' then

mid:='NOVEMBER';

elsif trim(tO_CHAR(:NEW.ORDER_DATE,'MONTH'))='DECEMBER' then

mid:='DECEMBER';

end if;

Y:= extract(year from :new.order_date);

M:=MID;

s_exists(:new.sid, n, M, Y);

if(n=1) then
update s_commission set commission=commission+comm where sid=:new.sid and month=mid
and year=extract(year from :new.order_date);

END IF;

if (n=0) then

insert into s_commission values(:NEW.SID, MID, EXTRACT(YEAR FROM :NEW.ORDER_DATE),


COMM);

END IF;

end;

SQL> insert into orders values('O15','C109','S104',3000,300,'20-dec-21',600);

1 row created.

SQL> SELECT * FROM S_COMMISSION;

SID MONTH YEAR COMMISSION

----- ---------- ---------- ----------

S104 DECEMBER 2021 2400

SQL> insert into orders values('O16','C109','S104',3000,300,'20-dec-22',600);

No records Found

1 row created.

SID MONTH YEAR COMMISSION

----- ---------- ---------- ----------

S104 DECEMBER 2021 2400


S104 DECEMBER 2022 3600

SQL> insert into orders values('O18','C109','S104',3000,300,'20-dec-22',600);

1 row created.

SQL> SELECT * FROM S_COMMISSION;

SID MONTH YEAR COMMISSION

----- ---------- ---------- ----------

S104 DECEMBER 2021 2400

S104 DECEMBER 2022 4800

4)set serveroutput on

create or replace procedure cust_proc(cust_id varchar,month varchar,year number)is

name varchar(10);

total number(20,2);

amount number(15,2);

cursor cust_cur is select cust_name,purchase_amt from customer natural join orders where cid=cust_id and
extract(year from order_date)=year and extract(month from order_date)=month;

begin

total:=0;

open cust_cur;

loop

fetch cust_cur into name,amount;

exit when cust_cur%notfound;

total:=total+amount;

end loop;
dbms_output.put_line('Total purchase amount is :'||total);

close cust_cur;

end;

SQL> @ d:purchase.sql

Procedure created.

set serveroutput on

declare

cust_id varchar(5);

month varchar(10);

year number(4);

id varchar(5);

begin

cust_id:='&customer_id';

select cid into id from customer where cid=cust_id;

month:=&month_in_number;

year:=&year;

cust_proc(cust_id,month,year);

exception

when no_data_found then

dbms_output.put_line('no record found');

end;

/
SQL> @ d:purchase1.sql

Enter value for customer_id: C101

old 7: cust_id:='&customer_id';

new 7: cust_id:='C101';

Enter value for month_in_number: 2

old 9: month:=&month_in_number;

new 9: month:=2;

Enter value for year: 2022

old 10: year:=&year;

new 10: year:=2022;

Total purchase amount is :2000

PL/SQL procedure successfully completed.


5. Consider the following schema for a Library Database:

BOOK_RETURN
Name Constraint BOOK_AUTHORS
Card_No Foreign Key references Name Constraint
Book_Lending Book_id Foreign Key references
Return_Date Not Null Book, Part of Primary Key
Fine Not Null, Default 0 Author_Name Not Null, Part of Primary
Key
BOOK
Name Constraint
Book_id Primary Key, must begin with B LIBRARY_BRANCH
Title Not Null Name Constraint
Publisher_Name Foreign Key references Publisher Branch_id Primary Key
Publishing_Year Not Null Branch_Nam Not Null
e
Address Not Null

BOOK_LENDING BOOK_COPIES
Name Constraint Name Constraint
Book_id Part of Foreign Key references Book_id Foreign Key references
Book_copies Book, Part of Primary Key
Branch_id Part of Foreign Key references Branch_id Foreign Key references
Book_copies Branch, Part of Primary Key
Card_No Primary Key No_of_Copies Not Null
Date_Out Not Null Avlbl_Copies Not Null
Due_Date Not Null
Bid F.K refers borrower

Borrower table (bid PK,bname not null,baddress not null)


Publisher table (name,address,phone unique)

Note: Give names to constraints.


Available_copies of book_copies table do not insert the value , it has to be calculated when you add to book_lending
table available_copies must be decreased by 1 and when you add to return table it should increase.

Write SQL queries to


1. Retrieve details of all books in the library – id, title, name of publisher, authors, number of copies in each
branch, etc.
2. Get the particulars of borrowers who have borrowed more than 3 books, but from Jan 2017 to Jun 2017.
3. Delete a book in BOOK table. Update the contents of other tables to reflect this data manipulation operation.
4. Create a view of all books and its number of copies that are currently available in the Library.

PL/SQL
1. Write PL/SQL to display total books in each branch.
2. Write a procedure to calculate the total number of books published by a publisher in the current year and last
two years.
3. Display the borrowed book names and their due_dates which are not yet returned (use set operation minus).
Create table publisher(

2 name varchar(10)constraint name_p primary key,

3 address varchar(10)not null,

4 phone number(10)constraint phone_p unique);

Table created.

SQL> create table borrower(

2 bid varchar(5)constraint bid primary key,

3 bname varchar(10)not null,

4 baddress varchar(10)not null);

Table created.

SQL> create table book(

2 book_id varchar(5)primary key constraint bkid check(book_id like 'B%'),

3 title varchar(10)not null,

4 pub_name varchar(10)constraint pname_bk references publisher on delete cascade,

5 pub_year number(5) not null);

Table created.

SQL> create table book_authors(

2 book_id varchar(5)constraint bkd references book on delete cascade,

3 author_name varchar(10)not null,

4 primary key(book_id,author_name));

Table created.
SQL> create table library_branch(

2 branch_idc varchar(5)constraint bridc primary key,

3 branch_name varchar(10)not null,

4 address varchar(10)not null);

Table created.

create table book_copies(

SQL> create table book_copies(

2 book_id varchar(5)constraint bid_bcpy references book on delete cascade,

3 branch_id varchar(5)constraint brnch_id references library_branch on delete cascade,

4 no_of_copies number(5)not null,

5 avlbl_copies number(5)not null,

6 primary key(book_id,branch_id));

Table created.

SQL> create table book_lending(

2 book_id varchar(5),

3 branch_id varchar(5),

4 cardno varchar(5)constraint cno primary key,

5 date_out date not null,

6 due_date date not null,

7 bid varchar(5)constraint bid_bk references borrower on delete cascade,

8 foreign key(book_id,branch_id)references book_copies on delete cascade);

Table created.

SQL> create table book_return(

2 cardno varchar(5)constraint crno references book_lending on delete cascade,

3 return_date date not null,

4 fine number(5)default 0 constraint fine not null);


Table created.

SQL> insert into publisher values('Kithabghar','manipal','9838239012');

1 row created.

SQL> insert into publisher values('bookhouse','udupi','9820957312');

1 row created.

SQL> select *from publisher;

NAME ADDRESS PHONE

---------- ---------- ----------

bharath banglore 9876543290

Ragavendra manglore 9830482390

Kithabghar manipal 9838239012

bookhouse udupi 9820957312

SQL> insert into borrower values('B4','kavya','manglore');

1 row created.

SQL> select *from borrower;

BID BNAME BADDRESS

----- ---------- ----------

B1 amrutha barkur

B2 anisha udupi
B3 bavya banglore

B4 kavya manglore

SQL> select *from book;

BOOK_ TITLE PUB_NAME PUB_YEAR

----- ---------- ---------- ----------

Bk01 beloved bharath 2022

Bk02 two states Ragavendra 2017

Bk03 The guide Kithabghar 2017

Bk04 Perfect us bookhouse 2017

SQL> insert into book_authors values('Bk04','chethan');

1 row created.

SQL> select *from book_authors;

BOOK_ AUTHOR_NAM

----- ----------

Bk01 Toni

Bk02 chethan

Bk03 Peter

Bk04 chethan

SQL> insert into library_branch values('br4','banglore','banglore');

1 row created.
SQL> select *from library_branch;

BRANC BRANCH_NAM ADDRESS

----- ---------- ----------

br1 udupi udupi

br2 manipal manipal

br3 manglore manglore

br4 banglore banglore

SQL> insert into book_copies values('Bk04','br1',32,32);

1 row created.

SQL> select *from book_copies;

BOOK_ BRANC NO_OF_COPIES AVLBL_COPIES

----- ----- ------------ ------------

Bk01 br1 10 10

Bk02 br2 20 20

Bk01 br2 10 10

Bk02 br3 15 15

Bk03 br3 15 15

Bk03 br4 17 17

Bk04 br4 17 17

Bk04 br2 17 17

Bk04 br1 32 32

9 rows selected.
SQL> insert into book_lending values('Bk02','br3','c8','09-sep-2017','12-oct-2017','B4');

1 row created.

SQL> select *from book_lending;

BOOK_ BRANC CARDN DATE_OUT DUE_DATE BID

----- ----- ----- --------- --------- -----

Bk01 br1 c1 12-JAN-17 12-FEB-17 B1

Bk02 br2 c2 12-JAN-17 12-FEB-17 B1

Bk04 br4 c3 12-MAR-17 12-APR-17 B1

Bk03 br3 c4 23-MAR-17 12-APR-17 B1

Bk03 br3 c5 23-APR-17 12-MAY-17 B2

Bk04 br4 c6 27-APR-17 12-MAY-17 B2

Bk01 br1 c7 27-APR-17 27-MAY-17 B3

Bk02 br3 c8 09-SEP-17 12-OCT-17 B4

8 rows selected.

SQL> insert into book_return values('c4','20-Apr-2017',10);

1 row created.

SQL> select *from book_return;

CARDN RETURN_DA FINE

----- --------- ----------

c1 20-FEB-17 20

c2 10-FEB-17 0

c3 10-APR-17 0
c4 20-APR-17 10

Query:

1)SQL> select *from publisher join book on(name=pub_name)

2 join book_authors on(book_authors.book_id=book.book_id)

3 join book_lending on(book.book_id=book_lending.book_id)

4 join book_copies on(book.book_id=book_copies.book_id)

5 join library_branch on(book_copies.branch_id=library_branch.branch_idc)

6 join book_return on(book_lending.cardno=book_return.cardno);

NAME ADDRESS PHONE BOOK_ TITLE PUB_NAME PUB_YEAR BOOK_

---------- ---------- ---------- ----- ---------- ---------- ---------- -----

AUTHOR_NAM BOOK_ BRANC CARDN DATE_OUT DUE_DATE BID BOOK_ BRANC NO_OF_COPIES

---------- ----- ----- ----- --------- --------- ----- ----- ----- ------------

AVLBL_COPIES BRANC BRANCH_NAM ADDRESS CARDN RETURN_DA FINE

------------ ----- ---------- ---------- ----- --------- ----------

bookhouse udupi 9820957312 Bk04 Perfect us bookhouse 2017 Bk04

chethan Bk04 br4 c3 12-MAR-17 12-APR-17 B1 Bk04 br1 32

32 br1 udupi udupi c3 10-APR-17 0

bharath banglore 9876543290 Bk01 beloved bharath 2017 Bk01

Toni Bk01 br1 c1 12-JAN-17 12-FEB-17 B1 Bk01 br1 10

10 br1 udupi udupi c1 20-FEB-17 20

NAME ADDRESS PHONE BOOK_ TITLE PUB_NAME PUB_YEAR BOOK_

---------- ---------- ---------- ----- ---------- ---------- ---------- -----

AUTHOR_NAM BOOK_ BRANC CARDN DATE_OUT DUE_DATE BID BOOK_ BRANC NO_OF_COPIES

---------- ----- ----- ----- --------- --------- ----- ----- ----- ------------

AVLBL_COPIES BRANC BRANCH_NAM ADDRESS CARDN RETURN_DA FINE


------------ ----- ---------- ---------- ----- --------- ----------

bookhouse udupi 9820957312 Bk04 Perfect us bookhouse 2017 Bk04

chethan Bk04 br4 c3 12-MAR-17 12-APR-17 B1 Bk04 br2 17

17 br2 manipal manipal c3 10-APR-17 0

bharath banglore 9876543290 Bk01 beloved bharath 2017 Bk01

Toni Bk01 br1 c1 12-JAN-17 12-FEB-17 B1 Bk01 br2 10

NAME ADDRESS PHONE BOOK_ TITLE PUB_NAME PUB_YEAR BOOK_

---------- ---------- ---------- ----- ---------- ---------- ---------- -----

AUTHOR_NAM BOOK_ BRANC CARDN DATE_OUT DUE_DATE BID BOOK_ BRANC NO_OF_COPIES

---------- ----- ----- ----- --------- --------- ----- ----- ----- ------------

AVLBL_COPIES BRANC BRANCH_NAM ADDRESS CARDN RETURN_DA FINE

------------ ----- ---------- ---------- ----- --------- ----------

10 br2 manipal manipal c1 20-FEB-17 20

Ragavendra manglore 9830482390 Bk02 two states Ragavendra 2017 Bk02

chethan Bk02 br2 c2 12-JAN-17 12-FEB-17 B1 Bk02 br2 20

20 br2 manipal manipal c2 10-FEB-17 0

Kithabghar manipal 9838239012 Bk03 The guide Kithabghar 2017 Bk03

NAME ADDRESS PHONE BOOK_ TITLE PUB_NAME PUB_YEAR BOOK_

---------- ---------- ---------- ----- ---------- ---------- ---------- -----

AUTHOR_NAM BOOK_ BRANC CARDN DATE_OUT DUE_DATE BID BOOK_ BRANC NO_OF_COPIES

---------- ----- ----- ----- --------- --------- ----- ----- ----- ------------

AVLBL_COPIES BRANC BRANCH_NAM ADDRESS CARDN RETURN_DA FINE

------------ ----- ---------- ---------- ----- --------- ----------


Peter Bk03 br3 c4 23-MAR-17 12-APR-17 B1 Bk03 br3 15

15 br3 manglore manglore c4 20-APR-17 10

Ragavendra manglore 9830482390 Bk02 two states Ragavendra 2017 Bk02

chethan Bk02 br2 c2 12-JAN-17 12-FEB-17 B1 Bk02 br3 15

15 br3 manglore manglore c2 10-FEB-17 0

NAME ADDRESS PHONE BOOK_ TITLE PUB_NAME PUB_YEAR BOOK_

---------- ---------- ---------- ----- ---------- ---------- ---------- -----

AUTHOR_NAM BOOK_ BRANC CARDN DATE_OUT DUE_DATE BID BOOK_ BRANC NO_OF_COPIES

---------- ----- ----- ----- --------- --------- ----- ----- ----- ------------

AVLBL_COPIES BRANC BRANCH_NAM ADDRESS CARDN RETURN_DA FINE

------------ ----- ---------- ---------- ----- --------- ----------

bookhouse udupi 9820957312 Bk04 Perfect us bookhouse 2017 Bk04

chethan Bk04 br4 c3 12-MAR-17 12-APR-17 B1 Bk04 br4 17

17 br4 banglore banglore c3 10-APR-17 0

Kithabghar manipal 9838239012 Bk03 The guide Kithabghar 2017 Bk03

Peter Bk03 br3 c4 23-MAR-17 12-APR-17 B1 Bk03 br4 17

17 br4 banglore banglore c4 20-APR-17 10

NAME ADDRESS PHONE BOOK_ TITLE PUB_NAME PUB_YEAR BOOK_

---------- ---------- ---------- ----- ---------- ---------- ---------- -----

AUTHOR_NAM BOOK_ BRANC CARDN DATE_OUT DUE_DATE BID BOOK_ BRANC NO_OF_COPIES

---------- ----- ----- ----- --------- --------- ----- ----- ----- ------------

AVLBL_COPIES BRANC BRANCH_NAM ADDRESS CARDN RETURN_DA FINE

------------ ----- ---------- ---------- ----- --------- ----------


9 rows selected

2) SQL> select book_lending.bid from book_lending join borrower

2 on(borrower.bid=book_lending.bid)

3 where book_lending.date_out between to_date('1-jan-2017','dd-mm-yy')

4 and to_date('1-jun-2017','dd-mm-yy')group by book_lending.bid having count(*)>=3;

BID

-----

B1

3) SQL> create view book_view as select book.book_id,title,pub_name,pub_year,avlbl_copies

from book join book_copies

on (book.book_id=book_copies.book_id);

View created.

4)SQL> delete from book where book_id='Bk01';

1 row deleted.

SQL> select *from book;

BOOK_ TITLE PUB_NAME PUB_YEAR

----- ---------- ---------- ----------

Bk02 two states Ragavendra 2017

Bk03 The guide Kithabghar 2017

Bk04 Perfect us bookhouse 2017

SQL> select *from book_authors;


BOOK_ AUTHOR_NAM

----- ----------

Bk02 chethan

Bk03 Peter

Bk04 chethan

SQL> select *from book_copies;

BOOK_ BRANC NO_OF_COPIES AVLBL_COPIES

----- ----- ------------ ------------

Bk02 br2 20 20

Bk02 br3 15 15

Bk03 br3 15 15

Bk03 br4 17 17

Bk04 br4 17 17

Bk04 br2 17 17

Bk04 br1 32 32

7 rows selected.

SQL> select *from book_lending;

BOOK_ BRANC CARDN DATE_OUT DUE_DATE BID

----- ----- ----- --------- --------- -----

Bk02 br2 c2 12-JAN-17 12-FEB-17 B1

Bk04 br4 c3 12-MAR-17 12-APR-17 B1

Bk03 br3 c4 23-MAR-17 12-APR-17 B1

Bk03 br3 c5 23-APR-17 12-MAY-17 B2

Bk04 br4 c6 27-APR-17 12-MAY-17 B2


Bk02 br3 c8 09-SEP-17 12-OCT-17 B4

6 rows selected.

PL/sql

1) set serveroutput on

declare

total_books number(5);

branch_name varchar(10);

cursor book_cur is select sum(no_of_copies),library_branch.branch_idc from book_copies right join


library_branch on(library_branch.branch_idc=book_copies.branch_id)group by library_branch.branch_idc;

begin

open book_cur;

dbms_output.put_line('branch_id total_books');

loop

fetch book_cur into total_books,branch_name;

exit when book_cur%notfound;

dbms_output.put_line(branch_name||' '||total_books);

end loop;

close book_cur;

end;

Output: SQL> ed d:book.sql

SQL> @ d:book.sql

branch_id total_books

br3 30

br2 47

br1 42
br4 34

PL/SQL procedure successfully completed.

2)
set serveroutput on
create or replace procedure proc_book(pbl_name varchar)is
total number(5);
cursor proc_cur is select sum(no_of_copies)from book_copies natural join
book where(pub_year=extract(year from sysdate)or pub_year=(extract(year
from sysdate)-1)or pub_year=(extract(year from sysdate)-2))and
pub_name=pbl_name;
begin
open proc_cur;
loop
fetch proc_cur into total;
exit when proc_cur%notfound;
dbms_output.put_line(pbl_name||' '||total);
end loop;
close proc_cur;
end;
/

sql>procedure2.sql

set serveroutput on
declare
p_name varchar(10);
begin
p_name:='&pub_name';
dbms_output.put_line('publisher_name total_books');
proc_book(p_name);
end;
/

Output:
SQL> ed d:procedure1.sql
SQL> @ d:procedure2.sql
Enter value for pub_name: bharath
old 4: p_name:='&pub_name';
new 4: p_name:='bharath';
publisher_name total_books
bharath 20

PL/SQL procedure successfully completed.


3) set serveroutput on

declare

name varchar(10);

due_date date;

cursor due_cur is select title,due_date from book join book_lending


on(book.book_id=book_lending.book_id)where due_date<sysdate and cardno in(select cardno from
book_lending minus select cardno from book_return);

begin

open due_cur;

dbms_output.put_line('Title Due_date');

loop

fetch due_cur into name,due_date;

exit when due_cur%notfound;

dbms_output.put_line(name||' '||due_date);

end loop;

end;

SQL> @ d:bookreturn.sql

Title Due_date

The guide 12-MAY-17

Perfect us 12-MAY-17

two states 12-OCT-17

Note:available copies:

4) set serveroutput on
create or replace trigger tr_blending
before insert on book_lending
referencing OLD as o New as n
for each row
begin
update book_copies set avlbl_copies=avlbl_copies-1 where
book_id=:n.book_id;
end;
/
SQL> @ d:bktrigger.sql

Trigger created.

SQL> insert into book_lending values('Bk01','br1','c9','10-may-2019','21-may-2019','B3');

1 row created.

SQL> select *from book_lending;

BOOK_ BRANC CARDN DATE_OUT DUE_DATE BID

----- ----- ----- --------- --------- -----

Bk01 br1 c1 12-JAN-22 12-FEB-22 B1

Bk02 br2 c2 12-JAN-17 12-FEB-17 B1

Bk04 br4 c3 12-MAR-17 12-APR-17 B1

Bk03 br3 c4 23-MAR-17 12-APR-17 B1

Bk03 br3 c5 23-APR-17 12-MAY-17 B2

Bk04 br4 c6 27-APR-17 12-MAY-17 B2

Bk01 br1 c7 27-APR-22 27-MAY-22 B3

Bk02 br3 c8 09-SEP-17 12-OCT-17 B4

Bk01 br1 c9 10-MAY-19 21-MAY-19 B3

9 rows selected.

SQL> select *from book_copies;

BOOK_ BRANC NO_OF_COPIES AVLBL_COPIES

----- ----- ------------ ------------

Bk01 br1 10 9
Bk02 br2 20 20

Bk01 br2 10 9

Bk02 br3 15 15

Bk03 br3 15 15

Bk03 br4 17 17

Bk04 br4 17 17

Bk04 br2 17 17

Bk04 br1 32 32

2) set serveroutput on

create or replace trigger tr_breturn

after insert on book_return

referencing OLD as o NEW as n

for each row

declare

b_id varchar(10);

begin

select book_id into b_id from book_lending where cardno=:n.cardno;

update book_copies set avlbl_copies=avlbl_copies+1 where book_id=b_id;

end;

SQL> @ d:bktrigger1.sql

Trigger created.

SQL> insert into book_return values('c5','10-may-2017',0);

1 row created.
SQL> insert into book_return values('c6','10-may-2017',0);

1 row created.

SQL> select *from book_copies;

BOOK_ BRANC NO_OF_COPIES AVLBL_COPIES

----- ----- ------------ ------------

Bk01 br1 10 9

Bk02 br2 20 20

Bk01 br2 10 9

Bk02 br3 15 15

Bk03 br3 15 16

Bk03 br4 17 18

Bk04 br4 17 18

Bk04 br2 17 18

Bk04 br1 32 33

9 rows selected.

You might also like