Programming Language Exercises (1)
Programming Language Exercises (1)
Sample:
DELIMITER {custom delimiter}
CREATE PROCEDURE {procedureName}([optional parameters])
BEGIN
// procedure body...
// procedure body...
END
{custom delimiter}
2. Create a table Product(prod_id varchar(5), stock int, max_lev int, min_lev int,
reorder_lev int)
Create a table Sales(inv_id varchar(5), prod_id varchar(5), qty int)
Create a table Purchase(ord_id varchar(5), prod_id varchar(5), qty int)
Create a trigger to update the product table by increasing the stock of the
product purchased in purchase table (after insertion in purchase (table) and
decreasing the stock of product sold for every sales in the sales table(After insertion
in sales table). Also check the max_stock level during purchase and the
min_stock_level during sales before insertions.
3. Create trigger before delete on the above Account table to check wether the
balance is less than the minimum balance otherwise don’t allow.
(20.12.2024): TRANSACTIONS
1. Write transaction T_item for the following
a. To insert a new record to the product table
b. To make purchase to maintain stock above min_level
c. To make sales to any two products
2. Write Transaction Acc_Trans to insert a new record to the above Account table,
To calculate the bonus for the account who holds max balance as
10% on balance and update the record by adding bonus
3. Create Transaction Roll_Del to
a. Delete all students who have secured <= 70
Save point S1
Display records
b. Delete all students who have secured <=80
Save point S2
Display records
a. Delete all students who have secured <= 90
Save point S3
Display records
Roll back to s3
Display records
Roll back to s2
Display records
Roll back to s1
Display records
Commit.