MySQL 5.0 FAQ: Stored Procedures and Functions
2873
B.4.12: Do stored procedures have a statement for raising application errors?
Not in MySQL 5.0. The SQL standard
SIGNAL
and
RESIGNAL
statements are implemented in MySQL
5.5.
B.4.13: Do stored procedures provide exception handling?
MySQL implements
HANDLER
definitions according to the SQL standard. See
Section 13.6.7.2,
“
DECLARE ... HANDLER
Syntax”
, for details.
B.4.14: Can MySQL 5.0 stored routines return result sets?
Stored procedures can, but stored functions cannot. If you perform an ordinary
SELECT
inside a stored
procedure, the result set is returned directly to the client. You need to use the MySQL 4.1 (or above)
client/server protocol for this to work. This means that—for instance—in PHP, you need to use the
mysqli
extension rather than the old
mysql
extension.
B.4.15: Is
WITH RECOMPILE
supported for stored procedures?
Not in MySQL 5.0.
B.4.16: Is there a MySQL equivalent to using
mod_plsql
as a gateway on Apache to talk
directly to a stored procedure in the database?
There is no equivalent in MySQL 5.0.
B.4.17: Can I pass an array as input to a stored procedure?
Not in MySQL 5.0.
B.4.18: Can I pass a cursor as an
IN
parameter to a stored procedure?
In MySQL 5.0, cursors are available inside stored procedures only.
B.4.19: Can I return a cursor as an
OUT
parameter from a stored procedure?
In MySQL 5.0, cursors are available inside stored procedures only. However, if you do not open a
cursor on a
SELECT
, the result will be sent directly to the client. You can also
SELECT INTO
variables.
See
Section 13.2.8, “
SELECT
Syntax”
.
B.4.20: Can I print out a variable's value within a stored routine for debugging purposes?
Yes, you can do this in a stored procedure, but not in a stored function. If you perform an ordinary
SELECT
inside a stored procedure, the result set is returned directly to the client. You will need to use
the MySQL 4.1 (or above) client/server protocol for this to work. This means that—for instance—in
PHP, you need to use the
mysqli
extension rather than the old
mysql
extension.
B.4.21: Can I commit or roll back transactions inside a stored procedure?
Yes. However, you cannot perform transactional operations within a stored function.
B.4.22: Do MySQL 5.0 stored procedures and functions work with replication?
Yes, standard actions carried out in stored procedures and functions are replicated from a master
MySQL server to a slave server. There are a few limitations that are described in detail in
Section 18.6,
“Binary Logging of Stored Programs”
.
B.4.23: Are stored procedures and functions created on a master server replicated to a slave?
Yes, creation of stored procedures and functions carried out through normal DDL statements on a
master server are replicated to a slave, so the objects will exist on both servers.
ALTER
and
DROP
statements for stored procedures and functions are also replicated.
B.4.24: How are actions that take place inside stored procedures and functions replicated?
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...