DBMS Lab Quetsions With Answer
DBMS Lab Quetsions With Answer
DBMS Lab Quetsions With Answer
6 BEGIN
7 FOR emp_rec in emp_cur
8 LOOP
9 dbms_output.put_line(emp_rec.proid ||' '|| emp_rec.qty);
10 END LOOP;
11 END;
12 /
Query: set serveroutput on
Query: EXECUTE disp(2);
Query: select Custid, Custname, Age, phno from customer where custid in (select custid
from HLoan intersect select custid from VLoan);
f. Create a procedure to print the Amount and HLoanid when the Custid is given
as the parameter.
Query: CREATE OR REPLACE PROCEDURE disp(pID IN HLoan.custid%type)
2 IS
3 CURSOR emp_cur is
4 Select HLoanid, amount from HLoan where custid = pID;
5 emp_rec emp_cur%rowtype;
6 BEGIN
7 FOR emp_rec in emp_cur
8 LOOP
9 dbms_output.put_line(emp_rec.HLoanid ||' '|| emp_rec.amount);
10 END LOOP;
11 END;
12 /
Query: set serveroutput on
Query: EXECUTE disp(2);
Begin
Update product set stock=stock 10;
End; /
d. Create a view which displays Proid, Prodesc and sum of quantity in sales.
Query: create view v as select sum(qty),proid from sales group by proid;
b. Update the interest with 1% when Accbal of the Custid >50% of Loan
Amount
Query: update account set accbal=accbal+(accbal * 0.01) where accbal > (select (amount
* 0.5) from loan);
BEGIN
SELECT sum(accbal) INTO acc_bal FROM account WHERE custid = 2;
RETURN acc_bal;
END; /
SQL> select em_dtl_func from dual;
c. Create a procedure which prints the Customer details whose sum of Accbal
>10000 using getBal function created by user above (in b)
Query: CREATE OR REPLACE PROCEDURE disp
IS
CURSOR emp_cur is
Select sum(accbal), custid from account group by custid having sum(accbal)>10000;
emp_rec emp_cur%rowtype;
BEGIN
FOR emp_rec in emp_cur
LOOP
dbms_output.put_line(emp_rec.custid);
END LOOP;
END;
/
Query: set serveroutput on
Query: EXECUTE disp(2);
14. Create Tables as follows by choosing appropriate data type and set the
necessary primary and foreign key constraints:
Product (Prodid, Prodesc, Price, Stock, Reord)
Sales (Salesid, Proid, qty)
a. Display the total amount (price * qty) of Sales made so far
Query: select totalamount as p.price*s.qty from product p, sales s where p.prodid=s.proid;
b. Create a Report (using Crystal Reports/ Any report generation tool) when
Given with a Proid generates the list of sales made with sum of quantity sold
15. Create Tables as follows by choosing appropriate data type and set the
necessary primary and foreign key constraints:
Customer (Custid, Custname, Addr, phno,panno)
13
16. Create Tables as follows by choosing appropriate data type and set the
necessary primary and foreign key constraints:
Product (Prodid, Prodesc, Price, Stock, Reord)
Sales (Salesid, Proid, qty)
a. Double the Reord value of Products with Price >500 and Reord <50
Query: update product set reord=reord*2 where price>500 and reord<50;
b. Create a Form to make a Sale entry (using VB/ VC++/Java).
c. Sale can be entered only for available products so display available Prodid in
the Form to Choose one among them for Sale Entry
Project for b & c