Monday, January 22, 2018

ORACLE - How get error text from PL/SQL function

Sometimes you need return from PL/SQL functions error code and error text too.
function Sql_Salary( pPeriod number, pErrorMessage out varchar2 ) return number
is
begin
  ...
  if i <> 0 then
    pErrorMessage := '..error message..';
    return( -1 );
  end if;  
  ...
  return( 0 );
end;  
Call it:
declare
  i number;
  sErrorMessage varchar2(500);
begin
  i := factory.an_p.Sql_Salary( '201801', sErrorMessage );
end;

No comments:

Post a Comment