Search Postgresql Archives

Logging in function with exception

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Attachment: signature.asc
Description: Digital signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux