sql – 在postgres中打印运行时消息

我们可以在postgres中使用RAISE NOTICE作为RAISERROR’等效的消息来在sql Server中显示’WITH NowAIT,还是有更好的方法在postgres查询运行时打印中间消息?请建议是否有更好的方法在postgres中打印运行时消息.
INSERT INTO tbl1 (col1) values (val1);
DO $$
begin
raise notice 'insert tbl1 done!';
end;
$$;
UPDATE tbl2 set col2='val2' where ...;
DO $$
begin
raise notice 'update tbl2 done!';
end;
$$;

我很抱歉,如果这段代码太难以评论,请建议一个更好的方法来做,谢谢

解决方法

是的,您可以像下面一样使用RAISE NOTICE.这是正确的你做的方式.
RAISE NOTICE 'i want to print % and %',var1,var2;

有关更多信息,请参见此处https://www.postgresql.org/docs/current/static/plpgsql-errors-and-messages.html

编辑:

begin
INSERT INTO tbl1 (col1) values (val1);
raise notice 'insert tbl1 done!';
end;

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...