我正在为no_data_found使用用户定义的异常,但仍然看到ORA-06512堆栈信息以及用户定义的异常ORA-20106。
ORA-20106: Problem in loading Affected Circle data
ORA-06512: at "SRUSER.ADD_AFFECTEDCIRCLE", line 30如何抑制ORA-06512堆栈信息?
这是我的密码
CREATE OR REPLACE FUNCTION get_circleID 
( v_circle_code  vf_circle.circle_code%TYPE)
RETURN vf_circle.circle_id%TYPE
IS
    return_value  vf_circle.circle_id%TYPE; 
BEGIN
    BEGIN
        SELECT circle_id INTO return_value
        FROM vf_circle
        WHERE circle_code = v_circle_code;
   END;
   RETURN return_value;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE_APPLICATION_ERROR(-20102, 'Circle Code is wrong or not available',TRUE);
END get_circleID;
/发布于 2013-08-05 19:08:15
我觉得有些人在错误/异常处理中请求更少的信息有点奇怪。我通常会尽可能多地在那里转储堆栈跟踪(越多越好!)但也许你是在一个有正当理由的环境下工作。
你在找这样的例子吗?
-- exception types and related error codes encapsulated 
-- into an application specific package
create or replace package expkg is
  dummy_not_found constant number := -20102;
  dummy_not_found_ex exception;
  -- numeric literal required
  pragma exception_init (dummy_not_found_ex, -20102);
  -- helper to hide a bit esoteric string handling
  -- call only in exception handler !
  function get_exception_text return varchar2;
end;
/
create or replace package body expkg is
  function get_exception_text return varchar2 is
  begin
    -- returns only the first line of a multiline string
    return regexp_substr(sqlerrm, '^.+$', 1, 1, 'm');
  end;
end;
/
begin
  declare
    v_dummy dual.dummy%type;
  begin
    select dummy into v_dummy from dual where dummy = 'A';
  exception
    -- convert exception type
    when no_data_found then
      raise_application_error(expkg.dummy_not_found, 'Not A dummy !', true);
  end;
exception
  when expkg.dummy_not_found_ex then
    -- DIY if the default format doesn't fit 
    dbms_output.put_line(expkg.get_exception_text);
end;
/输出:
ORA-20102: Not A dummy !https://stackoverflow.com/questions/18058352
复制相似问题