Friday, December 1, 2017

ORACLE - How handle pl/sql exception

Typical example for handling pl/sql exception (when no row is found in select):
is
  iCount number;
  /* take type from table field */
  iKategp factory.an_hr_table.kategp%type;
begin
...
  begin
    select kategp into iKategp
    from factory.an_hr_table 
    where
    osc = pOsc;
  exception
    when NO_DATA_FOUND then
      pErrorMessage := 'No data found for worker: ' || pOsc;
      return( -1 );
  end;
...

No comments:

Post a Comment