发生错误时如何在PL/SQL中查找行号,过程名称 [英] How to find out line number, procedure name in PL/SQL in case of an error

查看:112
本文介绍了发生错误时如何在PL/SQL中查找行号,过程名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用D2k 6i表单,并从存储的数据库(oracle9i)过程ORA-00001中获得表单上的错误:违反了唯一约束(.),但我无法找出它来自哪个过程. 有人可以帮我吗

I am using a D2k 6i form and getting the error on form from stored database(oracle9i) procedure ORA-00001:Unique constraint(.) violated but i m not able to trace out from which procedure it is coming. can anybody help me regarding this

推荐答案

经过大量研究(头部撞牙和咬牙切齿),我遇到了这种模式:

I've come across this pattern after much research, head banging and gnashing of teeth:

CREATE OR REPLACE PACKAGE BODY my_schema.package_name
IS

  PROCEDURE foo
  IS
  BEGIN
    -- Call stored procedures/functions that throw unhandled exceptions
  EXCEPTION
    WHEN OTHERS THEN
      DBMS_OUTPUT.PUT_LINE('ERROR! - '
        || DBMS_UTILITY.FORMAT_ERROR_STACK
        || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
  END foo;

END;

DBMS_UTILITY.FORMAT_ERROR_STACK函数似乎提供了错误代码和消息,而DBMS_UTILITY.FORMAT_ERROR_BACKTRACE似乎提供了诚实的善良堆栈跟踪,至少在Oracle 10g中具有行号和存储过程名称.

The DBMS_UTILITY.FORMAT_ERROR_STACK function seems to give the error code and message, and DBMS_UTILITY.FORMAT_ERROR_BACKTRACE seems to give an honest to goodness stack trace, complete with line numbers and stored procedure names in Oracle 10g at least.

我不确定这些功能在Oracle 9i中是否可用.即使对于Oracle 10g,我也找不到太多有关此类事情的信息,所以我认为我至少应该发布此答案,因为9i相当老(因此10g就可以了).

I'm not sure if those functions are available in Oracle 9i. I couldn't find much information about this sort of thing even for Oracle 10g, so I thought I would at least post this answer since 9i is quite old (and so it 10g for that matter).

这篇关于发生错误时如何在PL/SQL中查找行号,过程名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆