Google
 

Friday, December 7, 2007

stored procedure and function

Stored procedures and functions are routines that are created with CREATE PROCEDURE and CREATE FUNCTION statements. A routine is either a procedure or a function. A procedure is invoked using a CALL statement, and can only pass back values using output variables. A function can be called from inside a statement just like any other function (that is, by invoking the function's name), and can return a scalar value. Stored routines may call other stored routines.

- create procedure CREATE PROCEDURE sp_name ([proc_parameter[,...]]) [characteristic ...] routine_body

proc_parameter: [ IN OUT INOUT ] param_name type

- CREATE FUNCTION sp_name ([func_parameter[,...]]) RETURNS type [characteristic ...] routine_body

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 or statements

No comments: