0% found this document useful (1 vote)
2K views

Rdbms Solved

The document contains details of tables created to store customer, ticket, student and competition data. It also includes sample data inserted into these tables. Procedures and functions are defined to retrieve and manipulate the data. One procedure displays names of customers who booked tickets on a given date. A trigger is created to restrict booking tickets with a future travel date. A function is defined to return the number of competitions a student participated in for a given year by accepting student ID and year as parameters.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
2K views

Rdbms Solved

The document contains details of tables created to store customer, ticket, student and competition data. It also includes sample data inserted into these tables. Procedures and functions are defined to retrieve and manipulate the data. One procedure displays names of customers who booked tickets on a given date. A trigger is created to restrict booking tickets with a future travel date. A function is defined to return the number of competitions a student participated in for a given year by accepting student ID and year as parameters.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 59

BBACA.

GA RDBMS Solved Slips

BBACA.GA
BBACA.GA RDBMS Solved Slips
**********Slip no 1*************
Create table Customer(C_no number(5)primary key,C_name varchar2(30),C_city varchar2(30),C_ph varchar2(15));

insert into Customer values(101,'kiran','nashik',7896452136);

insert into Customer values(102,'vashnav','nashik',4896452136);

insert into Customer values(103,'manish','mumbai',8896452136);

insert into Customer values(104,'monali','pune',6956452179);

insert into Customer values(105,'kalayani','mumbai',7896452136);

insert into Customer values(106,'pratisha','nashik',7897542136);

SQL> select * from customer;

C_NO C_NAME C_CITY C_PH

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

101 kiran nashik 7896452136

102 vashnav nashik 4896452136

103 manish Mumbai 8896452136

104 monali pune 6956452179

105 kalayani Mumbai 7896452136

106 pratisha nashik 7897542136

Create table Ticket(T_no number(5),Bk_date date,fare number(6),Trv_date date,C_no number(5)references


Customer13);

insert into Ticket values(11,'11-jan-2015',350,'26-jan-2015',101);

insert into Ticket values(12,'12-feb-2015',350,'26-feb-2015',102);

insert into Ticket values(13,'13-march-2015',350,'26-march-2015',103);

insert into Ticket values(14,'14-april-2015',350,'26-april-2015',104);

insert into Ticket values(15,'15-june-2015',350,'26-june-2015',105);

insert into Ticket values(16,'16-dec-2015',350,'26-dec-2015',101);

insert into Ticket values(17,'17-jan-2015',350,'26-jan-2015',103);

select * from Ticket;

T_NO BK_DATE FARE TRV_DATE C_NO

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

11 11-JAN-15 350 26-JAN-15 101

BBACA.GA
BBACA.GA RDBMS Solved Slips
12 12-FEB-15 350 26-FEB-15 102

13 13-MAR-15 350 26-MAR-15 103

14 14-APR-15 350 26-APR-15 104

15 15-JUN-15 350 26-JUN-15 105

16 16-DEC-15 350 26-DEC-15 101

17 17-JAN-15 350 26-JAN-15 103

=================================================================================================

Q.1 Write a procedure to display names of customer who have booked bus on given date.

create or replace procedure p1(x IN Ticket.Bk_date%type)

is

cursor c1 is select C_NAME from customer,Ticket where customer.C_NO=Ticket.C_NO and Ticket.BK_DATE=x;

v1 c1%rowtype;

begin

open c1;

loop

fetch c1 into v1;

exit when c1%notfound;

dbms_output.put_line('*********************OUTPUT*****************');

dbms_output.put_line('Mr.'||v1.C_name||'Booked a bus on given date');

end loop;

close c1;

end;

declare

a Ticket.Bk_date%type;

begin

a:=&Enter_BOOKING_DATE;

BBACA.GA
BBACA.GA RDBMS Solved Slips
p1(a);

end;

Enter value for enter_booking_date: '12-FEB-15'

old 4: a:=&Enter_BOOKING_DATE;

new 4: a:='12-FEB-15';

*********************OUTPUT*****************

Mr.vashnavBooked a bus on given date

====================================================================================

Q.2 Write a trigger that restricts insertion of ticket having traveling date smaller

than booking date.(Raise user defined exception and give appropriate message)

create or replace trigger t3

before insert

on ticket

for each row

when(new.trv_date < new.bk_date)

declare

myexp exception;

begin

raise myexp;

exception

when myexp then

raise_application_error(-20001,'not allowed');

when others then

raise_application_error(-20002,'ERROR!!');

end;

BBACA.GA
BBACA.GA RDBMS Solved Slips

Trigger created.

insert into Ticket13 values(30,'30-jan-2015',350,'26-jan-2015',103);

*****************OUTPUT************************

SQL> insert into Ticket values(30,'30-jan-2015',350,'28-jan-2015',103);

insert into Ticket values(30,'30-jan-2015',350,'28-jan-2015',103)

ERROR at line 1:

ORA-20001: not allowed

ORA-06512: at "SCOTT.T3", line 7

ORA-04088: error during execution of trigger 'SCOTT.T3'

SQL> insert into Ticket13 values(30,'26-jan-2015',350,'28-jan-2015',103);

BBACA.GA
BBACA.GA RDBMS Solved Slips
***********************Slip no 2************************
create table student13(s_reg_no number(5)primary key,S_name varchar2(30)not null,S_class varchar2(9));

insert into student13 values(1,'nitin','Sy_bca');

insert into student13 values(2,'john','Sy_bba');

insert into student13 values(3,'martin','Ty_bca');

insert into student13 values(4,'joe','Ty_bca');

insert into student13 values(5,'manisha','Fy_bca');

insert into student13 values(6,'shital','Fy_bca');

SQL> select * from student13;

S_REG_NO S_NAME S_CLASS

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

1 nitin Sy_bca

2 john Sy_bba

3 martin Ty_bca

4 joe Ty_bca

5 manisha Fy_bca

6 shital Fy_bca

create table competition13(comp_no number(5)primary key,comp_name varchar2(30)not null,comp_type varchar(10));

insert into competition13 values(101,'cricket','sport');

insert into competition13 values(102,'debet','academic');

insert into competition13 values(103,'football','sport');

insert into competition13 values(104,'Quiz','academic');

insert into competition13 values(105,'chess','sport');

SQL> select * from competition13;

BBACA.GA
BBACA.GA RDBMS Solved Slips

COMP_NO COMP_NAME COMP_TYPE

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

101 cricket sport

102 debet academic

103 football sport

104 Quiz academic

105 chess sport

create table S_C13(s_reg_no number(5)references student13,comp_no number(5)references competition13,year


number(4));

insert into S_C13 values(1,101,2015);

insert into S_C13 values(2,102,2017);

insert into S_C13 values(1,103,2016);

insert into S_C13 values(4,104,2014);

insert into S_C13 values(5,105,2015);

insert into S_C13 values(1,102,2011);

insert into S_C13 values(1,103,2015);

insert into S_C13 values(1,104,2015);

insert into S_C13 values(1,102,2015);

insert into S_C13 values(3,103,2018);

SQL> select * from S_C13;

S_REG_NO COMP_NO YEAR

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

1 101 2015

2 102 2017

1 103 2016

4 104 2014

BBACA.GA
BBACA.GA RDBMS Solved Slips
5 105 2015

1 102 2011

1 103 2015

1 104 2015

1 102 2015

3 103 2018

============================================================================

Q.1) Write a function which will accept s_reg_no of student and returns total number of competition in which
student has participated in a given year.

create or replace function f1(n IN student13.s_reg_no%type,y IN S_C13.year%type)return number

is

res number(2);

begin

select count(*) into res from student13,competition13,S_C13 where student13.s_reg_no=S_C13.s_reg_no and


competition13.comp_no=S_C13.comp_no and student13.s_reg_no=n and S_C13.year=y;

return res;

end;

declare

res number(2);

a student13.s_reg_no%type;

b S_C13.year%type;

begin

a:=&Enter_S_REG_NO;

b:=&ENter_year;

res:=f1(a,b);

dbms_output.put_line('Student partcipated in=' || res);

BBACA.GA
BBACA.GA RDBMS Solved Slips
end;

OUTPUT

Enter value for enter_s_reg_no: 1

old 6: a:=&Enter_S_REG_NO;

new 6: a:=1;

Enter value for enter_year: 2015

old 7: b:=&ENter_year;

new 7: b:=2015;

Student partcipated in=4

PL/SQL procedure successfully completed.

=========================================================================

Q.2) Write a cursor which will display year wise details of competitions held. (Use parameterized cursor)

declare cursor c1(x IN S_C13.year%type)

is select competition13.comp_no,comp_name,comp_type from competition13,S_C13 order by S_C13.year;

v1 c1%rowtype;

x S_C13.year%type

begin

x:=&ENter_year;

open c1(x);

loop

fetch c1 into v1;

exit when c1%notfound;

dbms_output.put_line(v1.comp_no,v1.comp_name.v1.comp_type);

end loop;

close c1;

BBACA.GA
BBACA.GA RDBMS Solved Slips
end;

declare

cursor c1(x IN S_C13.year%type)

is

select competition13.comp_no,comp_name,comp_type,year from competition13,S_C13 where


competition13.comp_no=S_C13.comp_no and year=x;

v1 c1%rowtype;

y S_C13.year%type;

begin

y:=&enter_year;

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

dbms_output.put_line('comp_no '||' comp_name '||'. comp_type ');

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

open c1(y);

loop

fetch c1 into v1;

exit when c1%notfound;

dbms_output.put_line(v1.comp_no||' '||v1.comp_name||' '||v1.comp_type);

end loop;

close c1;

end;

Enter value for enter_year: 2015

old 8: y:=&enter_year;

new 8: y:=2015;

----------------OUTPUT-----------------

.comp_no.comp_name. comp_type

BBACA.GA
BBACA.GA RDBMS Solved Slips
---------------------------------

101 cricket sport

105 chess sport

103 football sport

104 Quizac ademic

102 debetac ademic

BBACA.GA
BBACA.GA RDBMS Solved Slips
**********************Slip no 3************************
create table owner13(o_no number(5)primary key,o_name varchar2(30)not null,o_city varchar2(30),o_ph varchar2(15));

insert into owner13 values(1,'Ankit','pune',98746512136);

insert into owner13 values(2,'pranav','nashik',23746512136);

insert into owner13 values(3,'naitik','pune',93446512136);

insert into owner13 values(4,'pandurang','thane',354746512136);

insert into owner13 values(5,'kiran','pune',9874634235136);

insert into owner13 values(6,'vibhav','rajpur',98723412136);

insert into owner13 values(7,'Ankit','pune',9874625536);

SQL> select * from owner13;

O_NO O_NAME O_CITY

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

O_PH

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

1 Ankit pune

98746512136

2 pranav nashik

23746512136

3 naitik pune

93446512136

4 pandurang thane

354746512136

5 kiran pune

9874634235136

BBACA.GA
BBACA.GA RDBMS Solved Slips

6 vibhav rajpur

98723412136

7 Ankit pune

9874625536

create table estate13(e_no number(5),e_type varchar2(30),e_city varchar2(30)not null,e_price varchar2(10),o_no


number(5)references owner13);

insert into estate13 values(1,'bungalow','nashik',1250000,7);

insert into estate13 values(2,'flat','nashik',14520000,6);

insert into estate13 values(3,'flat','pune',36521498,6);

insert into estate13 values(4,'bungalow','mumbai',78451296,5);

insert into estate13 values(5,'bungalow','malegaon',3698521,4);

insert into estate13 values(6,'land','thane',12457896,3);

insert into estate13 values(7,'flat','pune',36985223,2);

insert into estate13 values(8,'land','aurangabad',78965412,1);

SQL> select * from estate13;

E_NO E_TYPE E_CITY

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

E_PRICE O_NO

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

1 bungalow nashik

1250000 7

2 flat nashik

14520000 6

BBACA.GA
BBACA.GA RDBMS Solved Slips

3 flat pune

36521498 6

4 bungalow mumbai

78451296 5

5 bungalow malegaon

3698521 4

6 land thane

12457896 3

7 flat pune

36985223 2

8 land aurangabad

78965412 1

=============================================================================

Q.1) Write a procedure which will accept owner number and display details of all estates of given owner which
belongs to pune city.

create or replace procedure est(x IN owner13.o_no%type)

is

cursor c1 is

select e_no,e_type,e_city,e_price from estate13,owner13 where owner13.o_no=estate13.o_no and


owner13.o_no=x;

v1 c1%rowtype;

begin

BBACA.GA
BBACA.GA RDBMS Solved Slips
open c1;

loop

fetch c1 into v1;

exit when c1%notfound;

dbms_output.put_line('****************OUTPUT***********************');

dbms_output.put_line(v1.e_no||' '|| v1.e_type||' '||v1.e_city||'


'||v1.e_price);

end loop;

close c1;

end;

declare

a owner13.o_no%type;

begin

a:=&Enter_O_no;

est(a);

end;

****************OUTPUT***********************

8 land aurangabad 78965412

==============================================================================

Q.2) Write a cursor which will display year wise details of competitions held. (Use parameterized cursor)

declare

cursor c2

is

select * from estate13 order by estate13.e_type;

BBACA.GA
BBACA.GA RDBMS Solved Slips
v2 c2%rowtype;

begin

dbms_output.put_line('*************OUTPUT************');

open c2;

loop

fetch c2 into v2;

exit when c2%notfound;

dbms_output.put_line(v2.e_no||' '||v2.e_type||' '||v2.e_city||' '||v2.e_price);

end loop;

close c2;

end;

*************OUTPUT************

1bungalownashik1250000

4bungalowmumbai78451296

5bungalowmalegaon3698521

7flatpune36985223

3flatpune36521498

2flatnashik14520000

8landaurangabad78965412

6landthane12457896

BBACA.GA
BBACA.GA RDBMS Solved Slips
*****************SLlip no 4 ********************
create table bus13(bus_no number(5)primary key,capacity number(5),source varchar2(30),destination varchar2(30));

insert into bus13 values(101,30,'frences College','mahatmanagar');

insert into bus13 values(102,40,'J.b School','rajivnagar');

insert into bus13 values(103,20,'Neheru College','M.G road');

insert into bus13 values(104,50,'bytco school','daata nagar');

insert into bus13 values(105,30,'pune school','nashik road');

insert into bus13 values(106,20,'d.g.p College','mahatmanagar');

insert into bus13 values(107,30,'College','college road');

SQL> select * from bus13;

BUS_NO CAPACITY SOURCE DESTINATION

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

101 30 frences College mahatmanagar

102 40 J.b School rajivnagar

103 20 Neheru College M.G road

104 50 bytco school daata nagar

105 30 pune school nashik road

106 20 d.g.p College mahatmanagar

107 30 College college road

create table driver13(driver_no number(5)primary key,driver_name varchar2(30)not null,addr varchar2(50),age


varchar2(2),salary number(8),shift varchar2(30));

insert into driver13 values(11,'ankit','dhule',22,8000,'morning');

insert into driver13 values(12,'himanshu','nashik',22,10000,'evening');

insert into driver13 values(13,'chirag','malegaon',21,12000,'morning');

insert into driver13 values(14,'idris','dhule',25,18000,'evening');

insert into driver13 values(15,'vishal','nashik',32,12000,'morning');

insert into driver13 values(16,'akshay','malegaon',42,25000,'evening');

BBACA.GA
BBACA.GA RDBMS Solved Slips
insert into driver13 values(17,'parimal','pune',32,38000,'morning');

SQL> select * from driver13;

DRIVER_NO DRIVER_NAME

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

ADDR AG SALARY

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

SHIFT

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

11 ankit

dhule 22 8000

morning

12 himanshu

nashik 22 10000

evening

13 chirag

malegaon 21 12000

morning

14 idris

dhule 25 18000

evening

15 vishal

nashik 32 12000

morning

16 akshay

BBACA.GA
BBACA.GA RDBMS Solved Slips

malegaon 42 25000

evening

17 parimal

pune 32 38000

morning

create table b_d13(bus_no number(5)references bus13,driver_no number(5)references driver13,date_of_duty_alloted


date);

insert into b_d13 values(101,11,'20-jan-2017');

insert into b_d13 values(102,12,'21-jan-2017');

insert into b_d13 values(103,13,'23-jan-2017');

insert into b_d13 values(104,14,'22-jan-2017');

insert into b_d13 values(105,15,'25-jan-2017');

insert into b_d13 values(106,16,'23-jan-2017');

insert into b_d13 values(107,17,'22-jan-2017');

SQL> select * from b_d13;

BUS_NO DRIVER_NO DATE_OF_D

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

101 11 20-JAN-17

102 12 21-JAN-17

103 13 23-JAN-17

104 14 22-JAN-17

105 15 25-JAN-17

106 16 23-JAN-17

107 17 22-JAN-17

=====================================================================================

BBACA.GA
BBACA.GA RDBMS Solved Slips
Q.1) Write a function which will return name of driver having maximum salary.

create or replace function sal return number

is

res number(5);

begin

select max(driver13.salary) into res from driver13;

return res;

end;

declare

a number(5);

begin

a:=sal;

dbms_output.put_line('***********OUTPUT***********');

dbms_output.put_line('max salary is '||a);

end;

***********OUTPUT***********

max salary is 38000

==================================================================================

Q.2 Write a cursor which will display date wise bus and their driver details.

declare

cursor dri

is

BBACA.GA
BBACA.GA RDBMS Solved Slips
select driver13.driver_no,driver_name,addr,age,salary from driver13,b_d13 where
driver13.driver_no=b_d13.driver_no order by b_d13.date_of_duty_alloted;

v1 dri%rowtype;

begin

dbms_output.put_line('driver_no'||' '||'driver_name'||' '||'addr'||'


'||'age'||' '||'salary');

open dri;

loop

fetch dri into v1;

exit when dri%notfound;

dbms_output.put_line(v1.driver_no||' '||v1.driver_name||' '||v1.addr||'


'||v1.age||' '||v1.salary);

end loop;

close dri;

end;

***********OUTPUT***********

driver_no driver_name addr age salary

11 ankit dhule 2 28000

12 himanshu nashik 2 210000

14 idris dhule 2 518000

17 parimal pune 3 238000

16 akshay malegaon 4 225000

13 chirag malegaon 2 112000

15 vishal nashik 3 212000

========================================================================================

BBACA.GA
BBACA.GA RDBMS Solved Slips

BBACA.GA
BBACA.GA RDBMS Solved Slips
*************************Slip no 5********************************
create table drug13(d_no number(5)primary key,d_name varchar2(30)not null,company varchar2(30),price varchar2(5));

insert into drug13 values(1,'annecin','glaxo',3);

insert into drug13 values(2,'disprin','xyz',32);

insert into drug13 values(3,'crosin','abc',13);

insert into drug13 values(4,'kja','glaxo',23);

insert into drug13 values(5,'asd','glaxo',34);

insert into drug13 values(6,'aasdn','glaxo',41);

SQL> select * from drug13;

D_NO D_NAME COMPANY PRIC

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

1 annecin glaxo 3

2 disprin xyz 32

3 crosin abc 13

4 kja glaxo 23

5 asd glaxo 34

6 aasdn glaxo 41

create table medical_store13(m_no number(5)primary key,m_name varchar2(30)not null,med_city varchar2(15),ph_no


varchar2(15));

insert into medical_store13 values(1,'sai','prmpri',8796541236);

insert into medical_store13 values(2,'sai','pune',8774541236);

insert into medical_store13 values(3,'sai','pune',7845541236);

insert into medical_store13 values(4,'sai','prmpri',9596541236);

insert into medical_store13 values(5,'sai','prmpri',1279654128);

SQL> select * from medical_store13;

BBACA.GA
BBACA.GA RDBMS Solved Slips
M_NO M_NAME MED_CITY PH_NO

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

1 sai prmpri 8796541236

2 sai pune 8774541236

3 sai pune 7845541236

4 sai prmpri 9596541236

5 sai prmpri 1279654128

create table med_dg13(m_no number(5)references medical_store13,d_no number(5)references drug13,qty number(9));

insert into med_dg13 values(1,1,89);

insert into med_dg13 values(2,2,189);

insert into med_dg13 values(3,3,81);

insert into med_dg13 values(4,4,9);

insert into med_dg13 values(5,5,39);

insert into med_dg13 values(5,6,29);

insert into med_dg13 values(2,2,42);

SQL> select * from med_dg13;

M_NO D_NO QTY

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

1 1 89

2 2 189

3 3 81

4 4 9

5 5 39

2 2 42

5 6 29

===========================================================================

BBACA.GA
BBACA.GA RDBMS Solved Slips
Q.1)Write a package, which consists of one procedure and one function.

Pass drug number as a parameter to procedure and display details of that drug.

Pass city as a parameter to a function and return total number of medical_store

in given city.

create or replace package slip5 as

procedure p1(d drug13.d_name%type);

function f1(ct medical_store13.med_city%type)return number;

end slip5;

create or replace package body slip5 as

procedure p1(d drug13.d_name%type)is

v1 drug13.d_no%type;

v2 drug13.company%type;

v3 drug13.price%type;

begin

select d_no,company,price into v1,v2,v3 from drug13 where d_name=d;

dbms_output.put_line('drug NAME '||d);

dbms_output.put_line('drug NO '||v1);

dbms_output.put_line('drug COMPANY '||v2);

dbms_output.put_line('drug PRICE '||v3);

end p1;

function f1(ct medical_store13.med_city%type)return number is

cnt number(8):=0;

begin

select count(m_no) into cnt from medical_store13 where medical_store13.med_city=ct;

return cnt;

BBACA.GA
BBACA.GA RDBMS Solved Slips
end f1;

end slip5;

declare

a drug13.d_name%type;

b medical_store13.med_city%type;

res number(5);

begin

a:=&enterDrug_name;

b:=&enter_city;

slip5.p1(a);

res:=slip5.f1(b);

dbms_output.put_line('no of stores'||res);

end;

Enter value for enterdrug_name: 'crosin'

old 6: a:=&enterDrug_name;

new 6: a:='crosin';

Enter value for enter_city: 'pune'

drug NAME crosin

drug NO 3

drug COMPANY abc

drug PRICE 13

old 7: b:=&enter_city;

new 7: b:='pune';

no of stores2

BBACA.GA
BBACA.GA RDBMS Solved Slips

===================================================================================

Q.2) Write a trigger that restricts insertion and updation of drug having

price less than zero. (Raise user defined exception and

give appropriate message)

create or replace trigger slip5b

before update or insert

on drug13

for each row

when(new.price<=0)

declare

myexp exception;

begin

raise myexp;

exception

when myexp then

raise_application_error(-20001,'price should be greater than zero');

when others then

raise_application_error(-200001,'ERROR!!!!');

end;

*******************INPUT********************************

insert into drug13 values(7,'askar','glaxo',0);

SQL> insert into drug13 values(7,'askar','glaxo',0);

insert into drug13 values(7,'askar','glaxo',0)

*******************OUTPUT********************* *

BBACA.GA
BBACA.GA RDBMS Solved Slips
ERROR at line 1:

ORA-20001: price should be greater than zero

ORA-06512: at "SYSTEM.SLIP5B", line 7

ORA-04088: error during execution of trigger 'SYSTEM.SLIP5B'

=======================================================================================

BBACA.GA
BBACA.GA RDBMS Solved Slips
************************SLIP NO 6*********************************
create table train13(t_no number(5)primary key,t_name varchar2(30)not null);

insert into train13 values(10001,'Godavari');

insert into train13 values(10002,'Mandagini');

insert into train13 values(10003,'Rajdhani');

insert into train13 values(10004,'Raja-rani Exp');

insert into train13 values(10005,'CST');

SQL> select * from train13;

T_NO T_NAME

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

10001 Godavari

10002 Mandagini

10003 Rajdhani

10004 Raja-rani Exp

10005 CST

create table passenger13(p_no number(5)primary key,p_name varchar2(30)not null,addr varchar2(30),age number(2));

insert into passenger13 values(1,'vickey','nashik',23);

insert into passenger13 values(2,'vinay','pune',33);

insert into passenger13 values(3,'kiran','dhule',34);

insert into passenger13 values(4,'tushar','pune',21);

insert into passenger13 values(5,'rahul','nashik',26);

insert into passenger13 values(6,'harshal','mumbai',73);

insert into passenger13 values(7,'Manya','nashik',35);

SQL> select * from passenger13;

P_NO P_NAME ADDR

BBACA.GA
BBACA.GA RDBMS Solved Slips
---------- ------------------------------ ------------------------------

AGE

----------

1 vickey nashik

23

2 vinay pune

33

3 kiran dhule

34

4 tushar pune

21

5 rahul nashik

26

6 harshal mumbai

73

7 Manya nashik

35

create table t_p13(t_no number(5)references train13,p_no number(5)references passenger13,dt date,seat


number(8),amt number(9));

insert into t_p13 values(10001,1,'1-jan-2017',123,450);

insert into t_p13 values(10002,2,'2-jan-2017',124,120);

insert into t_p13 values(10003,4,'3-jan-2017',125,450);

BBACA.GA
BBACA.GA RDBMS Solved Slips
insert into t_p13 values(10004,3,'4-jan-2017',126,750);

insert into t_p13 values(10005,5,'5-jan-2017',127,650);

insert into t_p13 values(10002,6,'1-jan-2017',128,40);

insert into t_p13 values(10001,3,'6-jan-2017',129,120);

insert into t_p13 values(10002,1,'7-jan-2017',130,445);

SQL> select * from t_p13;

T_NO P_NO DT SEAT AMT

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

10001 1 01-JAN-17 123 450

10002 2 02-JAN-17 124 120

10003 4 03-JAN-17 125 450

10004 3 04-JAN-17 126 750

10005 5 05-JAN-17 127 650

10002 6 01-JAN-17 128 40

10001 3 06-JAN-17 129 120

10002 7 07-JAN-17 130 445

=====================================================================================

Q.1) Write a function which will display train details having maximum passenger for a given date.

create or replace function r1 return number

is

res number(2);

begin

select max(passenger13.p_no) into res from train13,passenger13,t_p13 where train13.t_no=t_p13.t_no and


passenger13.p_no=t_p13.p_no;

return res;

end;

declare

BBACA.GA
BBACA.GA RDBMS Solved Slips
a number(5);

begin

a:=r1();

dbms_output.put_line('max passenger '||a);

end;

***********OUTPUT**************

max passenger 6

=====================================================================

Q.2) Write a cursor which will display date wise train and their passenger details.

declare

cursor c1 is

select passenger13.p_no,p_name,addr,age from passenger13,t_p13 where passenger13.p_no=t_p13.p_no


order by t_p13.dt;

v1 c1%rowtype;

begin

dbms_output.put_line('************OUTPUT*************');

open c1;

loop

fetch c1 into v1;

exit when c1%notfound;

dbms_output.put_line(v1.p_no||v1.p_name||v1.addr||v1.age);

end loop;

close c1;

end;

************OUTPUT*************

1vickeynashik23

6harshalmumbai73

BBACA.GA
BBACA.GA RDBMS Solved Slips
2vinaypune33

4tusharpune21

3kirandhule34

5rahulnashik26

3kirandhule34

1vickeynashik23

******************Slip no 7********************
create table route13(route_no number(5)primary key,source varchar2(30),destnation varchar2(30),no_of_station
number(5));

insert into route13 values(11,'rajiv nagar','mumbai',6);

insert into route13 values(12,'vinay nagar','nashik',6);

insert into route13 values(13,'satpur','pune',6);

insert into route13 values(14,'mumbainaka','malegaon',6);

insert into route13 values(15,'nashik road','samjner',6);

SQL> select * from route13;

ROUTE_NO SOURCE DESTNATION

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

NO_OF_STATION

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

11 rajiv nagar mumbai

12 vinay nagar nashik

13 satpur pune

BBACA.GA
BBACA.GA RDBMS Solved Slips
6

14 mumbainaka malegaon

15 nashik road samjner

create table bus131(bus_no number(5),capicity number(5),depo_name varchar2(30),route_no number(5)references


route13);

insert into bus131 values(101,20,'nashik',11);

insert into bus131 values(102,10,'mumbai',12);

insert into bus131 values(103,30,'pune',13);

insert into bus131 values(104,50,'devlali',14);

insert into bus131 values(105,30,'samjner',15);

insert into bus131 values(106,90,'nashik',11);

SQL> select * from bus131;

BUS_NO CAPICITY DEPO_NAME ROUTE_NO

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

101 20 nashik 11

102 10 mumbai 12

103 30 pune 13

104 50 devlali 14

105 30 samjner 15

106 90 nashik 11

==================================================================================================
=

Q.1)Write a procedure which will display all bus details for a given route.

create or replace procedure p1(x IN route13.route_no%type) is

BBACA.GA
BBACA.GA RDBMS Solved Slips
cursor c1

is

select bus131.bus_no,source,destnation,no_of_station from bus131,route13 where


route13.route_no=bus131.route_no and route13.route_no=x;

v1 c1%rowtype;

begin

open c1(x);

loop

fetch c1 into v1;

exit when c1%notfound;

dbms_output.put_line(v1.bus_no||v1.bus_no||v1.source||v1.destnation||v1.no_of_station);

end loop;

close c1;

end;

create or replace procedure p1(x IN route13.route_no%type)

is

cursur c1

is

select bus131.bus_no,source,destnation,no_of_station from bus131,route13 where


route13.route_no=bus131.route_no and route_no=x;

v1 c1%rowtype;

x route13.route_no%type;

begin

open c1(x);

loop

fetch c1 into v1;

exit when c1%notfound;

dbms_output.put_line(v1.bus_no||v1.source||v1.destnation||v1.no_of_station);

BBACA.GA
BBACA.GA RDBMS Solved Slips
end loop;

close c1;

end;

=================================================================================

Q.2

BBACA.GA
BBACA.GA RDBMS Solved Slips
************************Slip no 8**************************
create table university13(u_no number(5)primary key,u_name varchar2(30),u_city varchar2(30));

insert into university13 values(1,'pune university13','pune');

insert into university13 values(2,'MGVM','nashik');

insert into university13 values(3,'YCMO','nashik');

insert into university13 values(4,'LPU','jalander');

SQL> select * from university13;

U_NO U_NAME U_CITY

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

1 pune university13 pune

2 MGVM nashik

3 YCMO nashik

4 LPU jalander

create table college13(c_no number(5),c_name varchar2(30),c_city varchar2(30),year_of_estb number(4),u_no


number(5)references university13);

insert into college13 values(1,'LVHM','nashik',1969,2);

insert into college13 values(2,'Ashoka ','nashik',2000,2);

insert into college13 values(3,'MVP','pune',1969,1);

insert into college13 values(4,'Rai High','nashik',1979,3);

insert into college13 values(5,'SKY HIGH','nashik',1989,1);

insert into college13 values(6,'Alfonsa','jalander',1789,4);

SQL> select * from college13;

C_NO_ C_NAME C_CITY

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

YEAR_OF_ESTB U_NO

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

BBACA.GA
BBACA.GA RDBMS Solved Slips
1 LVHM nashik

1969 2

3 MVP pune

1969 1

4 Rai High nashik

1979 3

5 SKY HIGH nashik

1989 1

6 Alfonsa jalander

1789 4

============================================================================

Q.1

create or replace package slip8 as

procedure p1(x IN university13.u_no%type);

function f1(a IN college13.c_city%type)return number;

end slip8;

create or replace package body slip8

as

procedure p1(x IN university13.u_no%type)

is

v1 university13.u_name%type;

BBACA.GA
BBACA.GA RDBMS Solved Slips
v2 university13.u_city%type;

begin

select u_name,u_city into v1,v2 from university13 where university13.u_no=x;

dbms_output.put_line('university13 no '||x||'university13 name '||v1||'university13 city '||v2);

end p1;

function f1(a IN college13.c_city%type)

return number is

cnt number(2):=0;

begin

select count(c_no) into cnt from college13 where college13.c_city=a;

return cnt;

end f1;

end slip8;

declare

x university13.u_no%type;

a college13.c_city%type;

cnt number(5);

begin

x:=&ENNTER_university13_no;

a:=&ENTER_CITY_name;

slip8.p1(x);

cnt:=slip8.f1(a);

dbms_output.put_line('Total is ='||cnt);

end;

BBACA.GA
BBACA.GA RDBMS Solved Slips
*******************OUTPUT*******************

Enter value for ennter_university13_no: 1

old 6: x:=&ENNTER_university13_no;

new 6: x:=1;

university13 no 1university13 name pune university13university13 city pune

Enter value for enter_city_name: 'nashik'

old 7: a:=&ENTER_CITY_name;

new 7: a:='nashik';

Total is =4

========================================================================================

Q.2

declare

cursor c1

is

select college13.c_no,c_name,c_city,year_of_estb from university13,college13 where


university13.u_no=college13.u_no;

v1 c1%rowtype;

begin

dbms_output.put_line('c_no||c_name||c_city||year_of_estb');

open c1;

loop

fetch c1 into v1;

exit when c1%notfound;

dbms_output.put_line(v1.c_no||v1.c_name||v1.c_city||v1.year_of_estb);

end loop;

close c1;

end;

BBACA.GA
BBACA.GA RDBMS Solved Slips
/

c_no c_name c_city year_of_estb

1 LVHM nashik 1969

2 Ashoka nashik 2000

3 MVP pune 1969

4 RaiHigh nashik 1979

5 SKYHIGH nashik 1989

6 Alfonsajalander 1789

BBACA.GA
BBACA.GA RDBMS Solved Slips
***************************Slip 11***********************************
create table researcher(r_no number(5)primary key,r_name varchar2(30)not null,r_city varchar2(30));

insert into researcher values(1,'akshay','nashik');

insert into researcher values(2,'ankit','pune');

insert into researcher values(3,'pranav','shirdi');

insert into researcher values(4,'anurag','surat');

insert into researcher values(5,'vishal','nagpur');

SQL> select * from researcher;

R_NO R_NAME R_CITY

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

1 akshay nashik

2 ankit pune

3 pranav shirdi

4 anurag surat

5 vishal nagpur

create table research_Paper(rp_no number(5)primary key,rp_title varchar2(30),rp_subject varchar2(30),rp_level


varchar2(30));

insert into research_Paper values(1,'Computer studies','computer','state');

insert into research_Paper values(2,'finance accounting','finance','state');

insert into research_Paper values(3,'ENTC','electronics','national');

insert into research_Paper values(4,'finance n finance','finance','international');

insert into research_Paper values(5,'Computer studies','electronics','state');

insert into research_Paper values(6,'Computer Exp','computer','international');

insert into research_Paper values(7,'Exp at electronics','electronics','state');

SQL> select * from research_paper;

RP_NO RP_TITLE RP_SUBJECT RP_LEVEL

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

1 Computer studies computer state

BBACA.GA
BBACA.GA RDBMS Solved Slips
2 finance accounting finance state

3 ENTC electronics national

4 finance n finance finance international

5 Computer studies electronics state

6 Computer Exp computer international

7 Exp at electronics electronics state

create table r_r(r_no number(5)references researcher,rp_no number(5)references research_paper,year number(4));

insert into r_r values(1,2,2015);

insert into r_r values(2,3,2015);

insert into r_r values(3,1,2015);

insert into r_r values(4,4,2015);

insert into r_r values(5,6,2015);

insert into r_r values(2,7,2015);

insert into r_r values(5,5,2015);

SQL> select * from r_r;

R_NO RP_NO YEAR

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

1 2 2015

2 3 2015

3 1 2015

4 4 2015

5 6 2015

2 7 2015

5 5 2015

============================================================================================

1) Write a procedure which will display details of research paper of a given subject for a specified year

create or replace procedure p1(x IN research_Paper.rp_subject,y IN r_r.year)

BBACA.GA
BBACA.GA RDBMS Solved Slips
is

cursur c1 is

select rp_no number,rp_title,rp_subject,rp_level

2) Write a trigger before insert or update of each row of research_paper published after 2010 be entered into
table.

(Raise user defined exception and give appropriate message)

BBACA.GA
BBACA.GA RDBMS Solved Slips
*******************************SLip no 13***********************************\
create table client(c_no number(5)primary key,c_name varchar2(30)not null,c_addr varchar2(30),brith_date date);

insert into client values(1,'ajay','vilasnagar','1-jan-1997');

insert into client values(2,'vijay','rajivnagar','23-feb-1987');

insert into client values(3,'kiran','vinaynagar','15-oct-1997');

insert into client values(4,'chirag','satpur','14-dec-1992');

insert into client values(5,'devesh','vilasnagar','15-nov-1979');

select * from client

C_NO C_NAME C_ADDR

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

BRITH_DAT

---------

1 ajay vilasnagar

01-JAN-97

2 vijay rajivnagar

23-FEB-87

3 kiran vinaynagar

15-OCT-97

4 chirag satpur

14-DEC-92

5 devesh vilasnagar

15-NOV-79

create table policy_info(p_no number(5)primary key,p_name varchar2(30)not null,maturity_amt number(10),prem_amt


number(10),policy_term number(4));

BBACA.GA
BBACA.GA RDBMS Solved Slips
insert into policy_info values(1,'Jivan bima',150000,150,5);

insert into policy_info values(2,'Jivan dai',200000,200,10);

insert into policy_info values(3,'saral',500000,400,15);

insert into policy_info values(4,'jandhan',1000000,1000,20);

select * from policy_info;

P_NO P_NAME MATURITY_AMT PREM_AMT POLICY_TERM

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

1 Jivan bima 150000 150 5

2 Jivan dai 200000 200 10

3 saral 500000 400 15

4 jandhan 1000000 1000 20

create table c_p(c_no number(5)references client,p_no number(5)references policy_info,dt_of_purchase date);

insert into c_p values(1,1,'2-jan-2010');

insert into c_p values(1,2,'16-feb-2011');

insert into c_p values(2,3,'23-june-2012');

insert into c_p values(2,4,'12-dec-2009');

insert into c_p values(3,1,'19-july-2006');

insert into c_p values(4,3,'19-july-2006');

insert into c_p values(5,4,'19-july-2006');

insert into c_p values(3,3,'19-july-2006');

select * from c_p;

C_NO P_NO DT_OF_PUR

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

1 1 02-JAN-10

1 2 16-FEB-11

BBACA.GA
BBACA.GA RDBMS Solved Slips
2 3 23-JUN-12

2 4 12-DEC-09

3 1 19-JUL-06

4 3 19-JUL-06

5 4 19-JUL-06

3 3 19-JUL-06

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Q.1)

create or replace procedure p1(x IN client.c_no%type,y IN c_p.dt_of_purchase%type)

is

cursor c1 is

select policy_info.p_no,p_name,maturity_amt,prem_amt,policy_term from client,policy_info,c_p where


client.c_no = c_p.c_no and policy_info.p_no=c_p.p_no and client.c_no=x and c_p.dt_of_purchase=y;

v1 c1%rowtype;

begin

open c1();

loop

fetch c1 into v1;

exit when c1%notfound;

dbms_output.put_line(v1.p_no||' '||v1.p_name||' '||v1.maturity_amt||'


'||v1.prem_amt||' '||v1.policy_term);

end loop;

close c1;

end;

declare

x client.c_no%type;

BBACA.GA
BBACA.GA RDBMS Solved Slips
y c_p.dt_of_purchase%type;

begin

x:=&Enterc_no;

y:=&Enterc_no_year;

p1(x,y);

end;

***************************Output*************************

Enter value for enterc_no: 3

old 5: x:=&Enterc_no;

new 5: x:=3;

Enter value for enterc_no_year: '19-JUL-06'

old 6: y:=&Enterc_no_year;

new 6: y:='19-JUL-06';

1 Jivan bima 150000 150 5

3 saral 500000 400 15

**************************************************************************

Q.2

create or replace trigger tr1

after or before

on policy_info

for each row

BBACA.GA
BBACA.GA RDBMS Solved Slips
************************Slip No28******************************
create table client(c_no number(5)primary key,c_name varchar2(30)not null,c_addr varchar2(30),brith_date date);

insert into client values(1,'ajay','vilasnagar','1-jan-1997');

insert into client values(2,'vijay','rajivnagar','23-feb-1987');

insert into client values(3,'kiran','vinaynagar','15-oct-1997');

insert into client values(4,'chirag','satpur','14-dec-1992');

insert into client values(5,'devesh','vilasnagar','15-nov-1979');

select * from client

C_NO C_NAME C_ADDR

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

BRITH_DAT

---------

1 ajay vilasnagar

01-JAN-97

2 vijay rajivnagar

23-FEB-87

3 kiran vinaynagar

15-OCT-97

4 chirag satpur

14-DEC-92

5 devesh vilasnagar

15-NOV-79

create table policy_info(p_no number(5)primary key,p_name varchar2(30)not null,maturity_amt number(10),prem_amt


number(10),policy_term number(4));

BBACA.GA
BBACA.GA RDBMS Solved Slips
insert into policy_info values(1,'Jivan bima',150000,150,5);

insert into policy_info values(2,'Jivan dai',200000,200,10);

insert into policy_info values(3,'saral',500000,400,15);

insert into policy_info values(4,'jandhan',1000000,1000,20);

select * from policy_info;

P_NO P_NAME MATURITY_AMT PREM_AMT POLICY_TERM

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

1 Jivan bima 150000 150 5

2 Jivan dai 200000 200 10

3 saral 500000 400 15

4 jandhan 1000000 1000 20

create table c_p(c_no number(5)references client,p_no number(5)references policy_info,dt_of_purchase date);

insert into c_p values(1,1,'2-jan-2010');

insert into c_p values(1,2,'16-feb-2011');

insert into c_p values(2,3,'23-june-2012');

insert into c_p values(2,4,'12-dec-2009');

insert into c_p values(3,1,'19-july-2006');

insert into c_p values(4,3,'19-july-2006');

insert into c_p values(5,4,'19-july-2006');

insert into c_p values(3,3,'19-july-2006');

select * from c_p;

C_NO P_NO DT_OF_PUR

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

1 1 02-JAN-10

1 2 16-FEB-11

BBACA.GA
BBACA.GA RDBMS Solved Slips
2 3 23-JUN-12

2 4 12-DEC-09

3 1 19-JUL-06

4 3 19-JUL-06

5 4 19-JUL-06

3 3 19-JUL-06

select c_p.p_no,p_name,c_no from policy_info,c_p where policy_info.p_no=c_p.p_no and c_p.p_no= (select


min(c_p.p_no) from c_p where c_p.p_no IN (select count(c_p.p_no) from c_p group by (c_p.p_no)));

============================================================================

select count(p_no),p_no from c_p group by (p_no);

select min((c_p.p_no)from c_p where p_no=(select count(p_no) from c_p);

select min(p_no) from c_p where p_no=(select count(p_no)from c_p group by (p_no) limit 1);

select min(c_p.p_no),c_p.p_no from c_p where c_p.p_no IN (select count(c_p.p_no) from c_p group by (c_p.p_no));

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

select min(c_p.p_no) from c_p where c_p.p_no IN (select count(c_p.p_no) from c_p group by (c_p.p_no));

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

select c_p.p_no,p_name from c_p,policy_info where c_p.p_no IN (select min(c_p.p_no) from c_p where c_p.p_no IN
(select count(c_p.p_no) from c_p group by (c_p.p_no)));

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

select min(c_p.p_no),policy_info.p_name from policy_info,c_p where (c_p.p_no IN (select count(c_p.p_no) from c_p
group by (c_p.p_no)) and policy_info.p_no=c_p.p_no);

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

select count(p_no),p_no from c_p group by (p_no);

BBACA.GA
BBACA.GA RDBMS Solved Slips
select count(p_no) from c_p order by (p_no) ;

select min(c_p.p_no)from c_p where p_no=(select count(p_no) from c_p);

select min(p_no),p_no from c_p where p_no= (select count(p_no) from c_p group by(p_no));

select z = (select count(p_no) from c_p group by(p_no)),p_no from c_p;

select p_name from client,policy_info,c_p where c_p.p_no= (select min(c_p.p_no) from client,policy_info,c_p where
client.c_no=c_p.c_no and policy_info.p_no=c_p.p_no group by(c_p.p_no));

=======================================================================

Q.1

declare

cursor c1 is select count(p_no),p_no from c_p group by(p_no);

v1 c1%rowtype;

m number(2):=0;

begin

open c1;

loop

fetch c1 into v1;

exit when c1%notfound;

BBACA.GA
BBACA.GA RDBMS Solved Slips

create or replace function f1()return varchar

is

res varchar2(30);

begin

select p_name into res from client,policy_info,c_p where p_no= (select min(p_no) from client,policy_info,c_p
where client.c_no=c_p.c_no and policy_info.p_no=c_p.p_no;

select p_name (select min(policy_info.p_no) from client,policy_info,c_p where client.c_no=c_p.c_no and


policy_info.p_no=c_p.p_no;

=========================================================================================

Q.2

declare

cursor c1(x IN client.c_no%type)

is

select policy_info.p_no,p_name,maturity_amt,prem_amt,policy_term from client,policy_info,c_p where


client.c_no=c_p.c_no and policy_info.p_no=c_p.p_no and client.c_no=x;

v1 c1%rowtype;

x client.c_no%type;

begin

x:=&enter_client_no;

dbms_output.put_line('Policy no Policy Name Maturity Amt Premier Amt Policy term');

dbms_output.put_line('======================================================================');

open c1(x);

loop

fetch c1 into v1;

exit when c1%notfound;

BBACA.GA
BBACA.GA RDBMS Solved Slips
dbms_output.put_line(v1.p_no||' '||v1.p_name||' '||v1.maturity_amt||'
'||v1.prem_amt||' '||v1.policy_term);

end loop;

close c1;

end;

+++++++++++++++++++OUTPUT++++++++++++++++++++++++

Enter value for enter_client_no: 1

old 8: x:=&enter_client_no;

new 8: x:=1;

Policy no Policy Name Maturity Amt Premier Amt Policy term

======================================================================

1 Jivan bima 150000 150 5

2 Jivan dai 200000 200 10

BBACA.GA
BBACA.GA RDBMS Solved Slips
**********************************slip 20************************************
create table drug13(d_no number(2)primary key,d_name varchar2(10)not null,company varchar2(10),price
number(10));

insert into drug13 values(1,'crocin','aa',320);

insert into drug13 values(2,'strepcill','bb',450);

insert into drug13 values(3,'zedex','cc',840);

insert into drug13 values(4,'brufen','dd',650);

insert into drug13 values(5,'vicks','ee',850);

SQL> SELECT * FROM DRUG13;

D_NO D_NAME COMPANY PRICE

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

1 crocin aa 320

2 strepcill bb 450

3 zedex cc 840

4 brufen dd 650

5 vicks ee 850

create table med_store13(m_no number(4)primary key,m_name varchar2(10)not null,m_city varchar2(10),ph_no


number(10));

insert into med_store13 values(1001,'apollo','pune',9856742535);

insert into med_store13 values(1002,'wokhart','Mumbai',9456872586);

insert into med_store13 values(1003,'umarao','pune',9784562135);

insert into med_store13 values(1004,'chaitanya','pimpri',9456872153);

insert into med_store13 values(1005,'Kimatlokh','pimpri',9023568475);

SQL> SELECT * FROM med_store13;

M_NO M_NAME M_CITY PH_NO

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

BBACA.GA
BBACA.GA RDBMS Solved Slips
1001 apollo pune 9856742535

1002 wokhart Mumbai 9456872586

1003 umarao pune 9784562135

1004 chaitanya pimpri 9456872153

1005 Kimatlokh pimpri 9023568475

create table quantity13(d_no number(2)references drug13,m_no number(4)references med_store13,quantity13


number(10));

insert into quantity13 values(1,1001,50);

insert into quantity13 values(4,1002,40);

insert into quantity13 values(2,1003,60);

insert into quantity13 values(3,1004,700);

insert into quantity13 values(2,1005,500);

insert into quantity13 values(1,1003,50);

insert into quantity13 values(5,1004,50);

insert into quantity13 values(5,1003,50);

insert into quantity13 values(4,1001,50);

SQL> SELECT * FROM quantity13;

D_NO M_NO QUANTITY13

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

1 1001 50

4 1002 40

2 1003 60

3 1004 700

2 1005 500

1 1003 50

BBACA.GA
BBACA.GA RDBMS Solved Slips
5 1004 50

5 1003 50

4 1001 50

Q1)

select count(drug13.d_no) from drug13,med_store13,quantity13 where drug13.d_no=quantity13.d_no and


med_store13.m_no=quantity13.m_no and med_store13.m_no=1001;

create or replace function f1(m IN quantity13.m_no%type)

return number

is

res number(2);

begin

select count(drug13.d_no) into res from drug13,med_store13,quantity13 where drug13.d_no=quantity13.d_no and


med_store13.m_no=quantity13.m_no and med_store13.m_no=m;

return res;

end;

**********************OUTPUT**********************

Enter value for enter_m_no: 1001

old 5: m:=&Enter_m_no;

new 5: m:=1001;

Total number of drug13s available in given medical store = 2

==================================================================

Q2)

BBACA.GA
BBACA.GA RDBMS Solved Slips
select quantity13.quantity13,drug13.d_no,drug13.d_name,drug13.company,drug13.price from
quantity13,drug13,med_store13 where drug13.d_no=quantity13.d_no and med_store13.m_no=quantity13.m_no and
med_store13.m_no=1001;

==================================================================

declare

cursor c1(x in med_store13.m_no%type)

is

select quantity13.quantity13,drug13.d_no,drug13.d_name,drug13.company,drug13.price from


quantity13,drug13,med_store13 where drug13.d_no=quantity13.d_no and med_store13.m_no=quantity13.m_no and
med_store13.m_no=x;

x med_store13.m_no%type;

v1 c1%rowtype;

begin

dbms_output.put_line('d_no d_name company price');

x:=&Enter_M_NO;

open c1(x);

loop

fetch c1 into v1;

exit when c1%notfound;

dbms_output.put_line(v1.d_no||v1.d_name||v1.company||v1.price);

end loop;

close c1;

end;

****************OUTPUT*************************

Enter value for enter_m_no: 1001

old 9: x:=&Enter_M_NO;

new 9: x:=1001;

BBACA.GA
BBACA.GA RDBMS Solved Slips

d_no d_name company price

1 crocin aa 320

4 brufen dd 650

BBACA.GA

You might also like