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

Programming Language Exercises (1)

Uploaded by

kalpanaapj
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Programming Language Exercises (1)

Uploaded by

kalpanaapj
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

29:11:2024: Write PL/SQL Procedures/ Functionsfor the following in my sql;

Sample:
DELIMITER {custom delimiter}
CREATE PROCEDURE {procedureName}([optional parameters])
BEGIN
// procedure body...
// procedure body...
END
{custom delimiter}

1. Creates a procedure named get_merit_students: to display all records of this


table whose marks are greater than 70 and count all the table rows.
2. Create procedure get_student with number of students to be displayed as input
parameter and display all the details of them.
3. Write procedure to get the stud_name who scores highest in the given department
4. Create mysql functioin to return the count of students in the Given Subject
5. Create mysql function to return the student name who have secured both the
Given Mark in the Given Subject

(06.12.2024) MYSQL CURSORS:


1. Create a mysql cursor to update all the stud_code with stud_code concatenated
with ‘_first_letter_of their name’
2. Create a mysql cursor to split the table into two below_avg and above_avg tables
by inserting the records if condition satisfy for below average and above average.
(13.12.2024) MYSQL TRIGGERS
1. Create a table name Account(acc_id int, amount decimal(10,2))
Write a before insert trigger to add the amount to @sum before inserting a
record to the table and print the sum after insertion as total_amt_inserted

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.

You might also like