MySQL 5.0 新特性教程 存储过程:第三讲


** The New SQL Statements 新SQL语句 **

Variables 变量

在复合语句中声明变量的指令是DECLARE。

(1) Example with two DECLARE statements

两个DECLARE语句的例子

CREATE PROCEDURE p8 ()

BEGIN

DECLARE a INT;

DECLARE b INT;

SET a = 5;

SET b = 5;

INSERT INTO t VALUES (a);

SELECT s1 * a FROM t WHERE s1 >= b;

END; // /* I won't CALL this */

在过程中定义的变量并不是真正的定义,你只是在BEGIN/END块内定义了而已(译注:也就是形参)。

Published At
Categories with 数据库类
comments powered by Disqus