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

Assignment 18

A MySQL database named 'assignment_18' is created with a table 'Employee' that includes employee ID, name, and salary. Five records are inserted into the Employee table with varying salaries. A stored procedure 'GetMaxSalary' is created to retrieve the maximum salary, which is successfully called to return a result of 60000.

Uploaded by

Mrinmoy Pathak
Copyright
© © All Rights Reserved
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)
6 views1 page

Assignment 18

A MySQL database named 'assignment_18' is created with a table 'Employee' that includes employee ID, name, and salary. Five records are inserted into the Employee table with varying salaries. A stored procedure 'GetMaxSalary' is created to retrieve the maximum salary, which is successfully called to return a result of 60000.

Uploaded by

Mrinmoy Pathak
Copyright
© © All Rights Reserved
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

mysql> use assignment_18;

Database changed
mysql>
mysql> CREATE TABLE Employee (
-> emp_id INT PRIMARY KEY,
-> name VARCHAR(255),
-> salary INT
-> );
Query OK, 0 rows affected (0.01 sec)

mysql>
mysql> INSERT INTO Employee (emp_id, name, salary)
-> VALUES
-> (1, 'raj', 20000),
-> (2, 'raja', 30000),
-> (3, 'nihar', 40000),
-> (4, 'nisha', 50000),
-> (5, 'niki', 60000);
Query OK, 5 rows affected (0.00 sec)
Records: 5 Duplicates: 0 Warnings: 0

mysql>
mysql> DELIMITER //
mysql> CREATE PROCEDURE GetMaxSalary(OUT max_salary INT)
-> BEGIN
-> SELECT MAX(salary) INTO max_salary FROM Employee;
-> END //
Query OK, 0 rows affected (0.00 sec)

mysql> DELIMITER ;
mysql>
mysql> CALL GetMaxSalary(@result);
Query OK, 1 row affected (0.00 sec)

mysql> SELECT @result;


+---------+
| @result |
+---------+
| 60000 |
+---------+
1 row in set (0.00 sec)

You might also like