存储过程2

来源:互联网 发布:中学生电脑编程大赛 编辑:程序博客网 时间:2024/05/17 07:30
存储过程,在命令行直接创建的话,在第五排你输入分号后就报错了。
因为MYSQL以为这个语句结束了,那对于MYSQL而言肯定是个错误语句。
如何解决这个问题呢?
只要在这个语句前后加分隔符就可以了。

DELIMITER //


drop procedure if exists proc_name;create procedure proc_name (in parameter integer)begindeclare variable varchar(20);if parameter = 1 thenset variable = 'MySQL';elseset variable = 'PHP';end if;select variable;end;  //call proc_name(1);//drop procedure if exists proc_name;create procedure proc_name (in parameter integer, out variableValue varchar(10))beginif parameter = 1 thenset variableValue = 'MySQL';elseset variableValue = 'PHP';end if;end;  //call proc_name(1, @variableValue);//select @variableValue;//


原创粉丝点击