简体   繁体   中英

MySQL return exact error/warning that stored procedure throws

This is my first time with Mysql SP. I've a procedure that does several DML operations like inserts and updates. But it sometimes throws a warning. I want to show that exact warning as it is(on shell/console) when the script is executed. Currently, I get something like below when an exception occurs.

Query OK, 0 rows affected, 1 warning (0.08 sec)

When I execute the same procedure using a mysql client like workbench and execute the procedure. I get a proper error message. This is what I want printed on console.

1   10:33:03    call dbscripts(@param)  0 row(s) affected, 1 warning(s): 1062 Duplicate entry '124' for key 'PRIMARY'

How can I do this?

Thanks

You can use SHOW WARNINGS . From the documentation :

SHOW WARNINGS shows information about the conditions (errors, warnings, and notes) that resulted from the last statement in the current session that generated messages.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM