mysql messagetext,系统变量“ MESSAGE_TEXT”在MySQL中不能使用SIGNAL语句?

My code is:i am using mysql 5.6 and workbench 6.3CE

CREATE DEFINER=`root`@`windows7test-pc` PROCEDURE `p`(divisor INT)

BEGIN

Declare MESSAGE_TEXT varchar(200);

IF divisor = 0 THEN

BEGIN

DECLARE my_error CONDITION FOR SQLSTATE '45000';

SIGNAL my_error;

set MESSAGE_TEXT='error occured in if block';

END;

END IF;

END

when i apply this stored procedure then i get no error but when i run this by calling call p(0) statement then i get only system error message which is Error Code: 1644

Unhandled user-defined exception condition.but my question is that why the mysql server not generate my error message whic is MESSAGE_TEXT='error occured in if block'; ?

解决方案

You do not declare message_text as a variable.

You do not DECLARE ... CONDITION.

You do have to include the values to SET in the same statement as SIGNAL.

The syntax is simply this:

IF divisor = 0 THEN

SIGNAL SQLSTATE '45000' SET message_text = 'division: ur doing it wrong';

END IF;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值