MySQL is known as the most popular open source RDBMS which is widely used by both community and enterprise. However during the first decade of its existence, it did not support stored procedure, trigger, event…etc. Since MySQL version 5.0, those features have been added to MySQL database engine to allow MySQL to be more flexible and powerful.
Before starting the tutorial series about stored procedure, it is required that you have MySQL version 5.x+ installed in your computer or server.
The advantages of using Stored Procedure
1. Programming a modular.2. Program execution is faster.
3. Reduce network traffic.
4. Can be used for security mechanisms.
format
:PROCEDURE sp_name ([proc_parameter[,...]]) [characteristic ...] routine_body
CREATE FUNCTION sp_name
[DEFINER = { user | CURRENT_USER }]
([func_parameter[,...]]) RETURNS type [characteristic ...] routine_body
proc_parameter:
[ IN | OUT | INOUT ] param_name type
func_parameter:
param_name type
type:
Any valid MySQL data type
characteristic:
LANGUAGE SQL | [NOT] DETERMINISTIC | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA } | SQL SECURITY { DEFINER | INVOKER } | COMMENT 'string'
routine_body:
Valid SQL procedure statement
0 comments
Post a Comment