Page 118 - Computer Software Application TP - Volume 1
P. 118
COMPUTER SOFTWARE APPLICATION - CITS
EXERCISE 31 : Creating & Using Stored procedure
Objectives
At the end of this exercise you shall be able to
• Create a stored procedure
• execute the stored procedure
• drop the stored procedure
Requirements
Tools/Materials
• Desktop/Laptop with latest configuration
• Operating system: window 10:11
• XAMPP server r3.3.0
Procedure
TASK 1 :Create and use stored procedure
1 Connect to Your Database:
mysql -u your username –p
Enter your password when prompted.
Select Your Database:
USE your database name;
Replace your database name with the name of your actual database.
2 Create a simple Stored Procedure:
In this example, the stored procedure will concatenate “Hello, “ with the input parameter and return the result.
DELIMITER //
CREATE PROCEDURE GetGreeting(IN input name VARCHAR(50), OUT greeting result VARCHAR(100))
BEGIN
SET greeting result = CONCAT(‘Hello, ‘, input name);
END //
DELIMITER ;
103
CITS : IT & ITES - Computer Software Application - Exercise 30