0% found this document useful (0 votes)
96 views1 page

PL SQL Exercise9

The document describes creating tables and inserting sample data. It then lists 4 triggers to be created: 1) a before insert trigger on Ord_dtl to increase the booked quantity in Prod_mst, 2) a before delete trigger on Ord_dtl to decrease the booked quantity in Prod_mst, 3) a before update trigger on Ord_dtl to increase/decrease the booked quantity in Prod_mst based on product code or quantity updates, and 4) a before update trigger on Ord_mst to decrease the booked quantity and stock quantity in Prod_mst if the status is changed to delivered, or delete the order details and decrease the booked quantity if the status is changed

Uploaded by

Sumit Tembhare
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views1 page

PL SQL Exercise9

The document describes creating tables and inserting sample data. It then lists 4 triggers to be created: 1) a before insert trigger on Ord_dtl to increase the booked quantity in Prod_mst, 2) a before delete trigger on Ord_dtl to decrease the booked quantity in Prod_mst, 3) a before update trigger on Ord_dtl to increase/decrease the booked quantity in Prod_mst based on product code or quantity updates, and 4) a before update trigger on Ord_mst to decrease the booked quantity and stock quantity in Prod_mst if the status is changed to delivered, or delete the order details and decrease the booked quantity if the status is changed

Uploaded by

Sumit Tembhare
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

PL*SQL Exercise 9

Create the following 3 tables and insert sample data as shown:Ord_mst Ord_no 1 Ord_dtl Ord_no 1 1 Prod_mst Prod_cd P1 P2 P3

Cust_cd C1

Status P

Prod_cd P1 P2

Qty 100 200

Prod_name Floppies Printers Modems

Qty_in_stock 10000 5000 3000

Booked_qty 1000 600 200

1. Write a Before Insert trigger on Ord_dtl. Anytime a row is inserted in Ord_dtl, the Booked_qty in Prod_mst should be increased accordingly. 2. Write a Before Delete trigger on Ord_dtl. Anytime a row is deleted from Ord_dtl, the Booked_qty in Prod_mst should be decreased accordingly. 3. Write a Before Update of Prod_cd, Qty trigger on Ord_dtl. Anytime the Prod_cd or Qty is updated, the Booked_qty in Prod_mst should be increased/decreased accordingly. 4. Write a Before Update of Status trigger on Ord_mst. If the Status is updated from P (Pending) to D (Delivered), the Booked_qty and Qty_in_stock from Prod_mst should be decreased accordingly. If the Status is updated from P (Pending) to C (Cancelled), the details of the order should be deleted from Ord_dtl and corresponding Booked_qty from Prod_mst should be decreased accordingly. (The Before delete trigger on Ord_dtl would automatically decrease the Booked_qty from Prod_mst).

Sameer Dehadrai

Page: 1

You might also like