Implementation of SQLCODE and SQLERRM variables for PL/pgSQL

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Implementation of SQLCODE and SQLERRM variables for PL/pgSQL
Дата
Msg-id Pine.LNX.4.44.0503062003220.32436-600000@kix.fsv.cvut.cz
обсуждение исходный текст
Ответ на Re: Exception ERROR Code  (Pavel Stehule <stehule@kix.fsv.cvut.cz>)
Ответы Re: Implementation of SQLCODE and SQLERRM variables for PL/pgSQL
Список pgsql-hackers
Hello

  This is my second patch, than please will be tolerant :-). For one my
project I miss information about exception when I use EXCEPTION WITH
OTHERS THEN. I found two Oracle's varaibles SQLCODE and SQLERRM which
carry this information. With patch you can:


--
-- Test of built variables SQLERRM and SQLCODE
--

create or replace function trap_exceptions() returns void as $_$
begin
  begin
    raise exception 'first exception';
  exception when others then
    raise notice '% %', SQLCODE, SQLERRM;
  end;
  raise notice '% %', SQLCODE, SQLERRM;
  begin
    raise exception 'last exception';
  exception when others then
    raise notice '% %', SQLCODE, SQLERRM;
  end;
  return;
end; $_$ language plpgsql;

select trap_exceptions();

drop function trap_exceptions();

CREATE FUNCTION
NOTICE:  P0001 first exception
NOTICE:  000000 Sucessful completion
NOTICE:  P0001 last exception
 trap_exceptions
-----------------

(1 row)

DROP FUNCTION


Regards,
Pavel Stehule

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Speeding up tupledesc copying
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Implementation of SQLCODE and SQLERRM variables for PL/pgSQL