Logging in function with exception

Поиск
Список
Период
Сортировка
От Gerhard Heift
Тема Logging in function with exception
Дата
Msg-id 20081110153130.GA11099@toaster.kawo1.rwth-aachen.de
обсуждение исходный текст
Ответы Re: Logging in function with exception  ("Asko Oja" <ascoja@gmail.com>)
Список pgsql-general
Hello,

I write funktions in pl/pgsql and want to abort it. For this I use raise
exception, to undo all changes for this transaction. Now I want to log
these exceptions somewhere.

DECLARE
  a integer;
  log_id integer;
BEGIN
  SELECT a INTO b FROM c WHERE d = 10;
  IF NOT FOUND THEN
    INSERT INTO log (logtype, logtext)
      VALUES ('error', 'Dit not found 10 in table')
      RETURNING id INTO log_id;
    RAISE EXCEPTION 'internal_error: %', log_id;
  END IF;
  -- anything else
END;

I know that these logs well be discard, if the commit rolls back.

Is there a possible way to implement something like this?

Thanks,
  Gerhard

Вложения

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: LIKE, "=" and fixed-width character fields
Следующее
От: Gerhard Heift
Дата:
Сообщение: Re: Get interval in months