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

Assignment 20

The document outlines the creation of a MySQL database named 'assignment_20' and a table 'Employee' with fields for employee ID, name, and salary. It includes the insertion of five employee records and the creation of a stored procedure 'GetEmployeeSalary' to retrieve an employee's salary based on their ID. Finally, it demonstrates calling the procedure to get the salary of an employee, resulting in a salary of 60000.00 for the employee with ID 2.

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)
2 views1 page

Assignment 20

The document outlines the creation of a MySQL database named 'assignment_20' and a table 'Employee' with fields for employee ID, name, and salary. It includes the insertion of five employee records and the creation of a stored procedure 'GetEmployeeSalary' to retrieve an employee's salary based on their ID. Finally, it demonstrates calling the procedure to get the salary of an employee, resulting in a salary of 60000.00 for the employee with ID 2.

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_20;

Database changed
mysql>
mysql>
mysql> CREATE TABLE Employee (
-> emp_id INT PRIMARY KEY,
-> emp_name VARCHAR(255),
-> emp_salary DECIMAL(10, 2)
-> );
Query OK, 0 rows affected (0.01 sec)

mysql>
mysql> INSERT INTO Employee (emp_id, emp_name, emp_salary)
-> VALUES
-> (1, 'John Doe', 50000.00),
-> (2, 'Jane Smith', 60000.00),
-> (3, 'Bob Johnson', 55000.00),
-> (4, 'Alice Brown', 52000.00),
-> (5, 'Charlie Wilson', 58000.00);
Query OK, 5 rows affected (0.00 sec)
Records: 5 Duplicates: 0 Warnings: 0

mysql>
mysql> DELIMITER //
mysql> CREATE PROCEDURE GetEmployeeSalary(IN in_emp_id INT, OUT out_salary
DECIMAL(10, 2))
-> BEGIN
-> SELECT emp_salary INTO out_salary
-> FROM Employee
-> WHERE emp_id = in_emp_id;
-> END //
Query OK, 0 rows affected (0.00 sec)

mysql> DELIMITER ;
mysql>
mysql> CALL GetEmployeeSalary(2, @salary);
Query OK, 1 row affected (0.00 sec)

mysql> SELECT @salary;


+----------+
| @salary |
+----------+
| 60000.00 |
+----------+
1 row in set (0.00 sec)

You might also like