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);

你可能感兴趣的:(mysql存储过程输出)