您现在的位置是:课程教程文章

postgresql怎么打印错误信息

2023-12-18 19:47课程教程文章 人已围观

如何抛出具体哪一行的错误,在oracle里面,可以用dbms_utility.format_error_backtrace打印具体的错误行号,

在pgsql里面,怎么打印呢?

do
$$
declare
v_num int ;
v_text1 text;
v_text2 text;
begin
   v_num:=1/0;
exception when others
    then get stacked diagnostics v_text1= MESSAGE_TEXT,
                                 v_text2=PG_EXCEPTION_CONTEXT;
    --raise notice '异常:%,%',sqlstate ,sqlerrm;
    raise notice '异常:%,%',v_text1,v_text2;
end;
$$;
--其中,PG_EXCEPTION_CONTEXT会报告具体的错误行;排查错误很方便;

更多技术请关注Python视频教程。

课程教程:postgresql怎么打印错误信息

上一篇:postgresql数据库如何打开

下一篇:没有了

站点信息

  • 文章统计篇文章