mysql存储过程输出_从MySQL中的存储过程打印调试信息

bd96500e110b49cbb3cd949968f18be7.png

Is there a way in MySQL to print debugging messages to stdout, temptable or logfile? Something like:

print in SQLServer

DBMS_OUTPUT.PUT_LINE in Oracle

解决方案

Option 1: Put this in your procedure to print 'comment' to stdout when it runs.

SELECT 'Comment';

Option 2: Put this in your procedure to print a variable with it to stdout:

declare myvar INT default 0;

SET myvar = 5;

SELECT concat('myvar is ', myvar);

This prints myvar is 5 to stdout when the procedure runs.

Option 3, Create a table with one text column called tmptable, and push messages to it:

declare myvar INT default 0;

SET myvar = 5;

insert into tmptable select concat('myvar is ', myvar);


版权声明:本文为weixin_34110970原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。