How to throw an error in MySql procedure?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了How to throw an error in MySql procedure?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1853字,纯文字阅读大概需要3分钟。
内容图文
![How to throw an error in MySql procedure?](/upload/InfoBanner/zyjiaocheng/470/47159d4f2ecf4ea1a1bfda31cfefb07a.jpg)
What is the mechanism to force the MySQL to throw an error within the stored procedure?
I have a procedure which call s another function:
PREPARE my_cmd FROM @jobcommand;
EXECUTE my_cmd;
DEALLOCATE PREPARE my_cmd;
the job command is:
jobq.exec("Select 1;wfdlk# to simulatte an error");
then:
CREATE PROCEDURE jobq.`exec`(jobID VARCHAR(128),cmd TEXT)
BEGIN
DECLARE result INT DEFAULT 0;
SELECT sys_exec( CONCAT(‘echo ‘,cmd,‘ | base64 -d > ‘, ‘/tmp/jobq.‘,jobID,‘.sh ; bash /tmp/jobq.‘,jobID,‘.sh &> /tmp/jobq.‘,jobID)) INTO result;
IF result>0 THEN
# call raise_mysql_error(result);
END IF;
END;
My jobq.exec
is always succeeding. Are there way to rise an error? How to implement raise_mysql_error function??
BTW I am using MySQL 5.5.8
thanks Arman.
mysql stored-procedures throw stored-functionsshareimprove this question |
asked Feb 1 ‘11 at 13:06
![]() |
|
related : stackoverflow.com/questions/465727/… – Haim Evgi Feb 1 ‘11 at 13:09 | ||
|
also read this chapter docstoc.com/docs/687360/Error-Handling-In-Stored-Procedure – Haim Evgi Feb 1 ‘11 at 13:11 |
2 Answers
activeoldestvotesup vote7down voteaccepted |
Yes, there is: use the
|
||||
|
up vote5down vote |
You may use following stored procedure to emulate error-throwing:
Example:
|
How to throw an error in MySql procedure?
标签:
本文系统来源:http://www.cnblogs.com/kungfupanda/p/5887410.html
内容总结
以上是互联网集市为您收集整理的How to throw an error in MySql procedure?全部内容,希望文章能够帮你解决How to throw an error in MySql procedure?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。