Oracle 5.0 Reference Manual page 1045

Table of Contents

Advertisement

CREATE PROCEDURE
Note
Specifying a parameter as IN, OUT, or
For a FUNCTION, parameters are always regarded as
An
parameter passes a value into a procedure. The procedure might modify the value, but the
IN
modification is not visible to the caller when the procedure returns. An
from the procedure back to the caller. Its initial value is
visible to the caller when the procedure returns. An
be modified by the procedure, and any change made by the procedure is visible to the caller when the
procedure returns.
For each
or
OUT
INOUT
the procedure so that you can obtain its value when the procedure returns. If you are calling the
procedure from within another stored procedure or function, you can also pass a routine parameter or
local routine variable as an
Routine parameters cannot be referenced in statements prepared within the routine; see
"Restrictions on Stored
The following example shows a simple stored procedure that uses an
mysql>
delimiter //
mysql>
CREATE PROCEDURE simpleproc (OUT param1 INT)
->
BEGIN
->
SELECT COUNT(*) INTO param1 FROM t;
->
END//
Query OK, 0 rows affected (0.00 sec)
mysql>
delimiter ;
mysql>
CALL simpleproc(@a);
Query OK, 0 rows affected (0.00 sec)
mysql>
SELECT @a;
+------+
| @a
|
+------+
| 3
|
+------+
1 row in set (0.00 sec)
The example uses the
while the procedure is being defined. This enables the
//
passed through to the server rather than being interpreted by
Stored
Programs".
The
clause may be specified only for a FUNCTION, for which it is mandatory. It indicates
RETURNS
the return type of the function, and the function body must contain a
the
statement returns a value of a different type, the value is coerced to the proper type.
RETURN
For example, if a function specifies an
statement returns an integer, the value returned from the function is the string for the corresponding
member of set of
ENUM
The following example function takes a parameter, performs an operation using an SQL function, and
returns the result. In this case, it is unnecessary to use
contains no internal
statement delimiters:
;
mysql>
CREATE FUNCTION hello (s CHAR(20))
mysql>
RETURNS CHAR(50) DETERMINISTIC
->
RETURN CONCAT('Hello, ',s,'!');
Query OK, 0 rows affected (0.00 sec)
mysql>
SELECT hello('world');
+----------------+
and
CREATE FUNCTION
parameter, pass a user-defined variable in the
or
parameter.
IN
INOUT
Programs".
client
mysql
delimiter
or
ENUM
members.
SET
1025
Syntax
is valid only for a PROCEDURE.
INOUT
within the procedure, and its value is
NULL
parameter is initialized by the caller, can
INOUT
OUT
command to change the statement delimiter from
delimiter used in the procedure body to be
;
itself. See
mysql
RETURN value
value in the
SET
RETURNS
because the function definition
delimiter
parameters.
IN
parameter passes a value
OUT
statement that invokes
CALL
Section E.1,
parameter:
Section 18.1, "Defining
statement. If
clause, but the
RETURN
to
;

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents