error handling

From: "Little, Douglas" <DOUGLAS(dot)LITTLE(at)orbitz(dot)com>
To: "PostgreSQL General (pgsql-general(at)postgresql(dot)org)" <pgsql-general(at)postgresql(dot)org>
Subject: error handling
Date: 2012-06-20 13:56:04
Message-ID: 8585BA53443004458E0BAA6134C5A7FBADD4CD8C@EGEXCMB01.oww.root.lcl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

Greenplum 4.1.2.4 (PG 8.2.3)
We are revising how we implement functions in order to better capture and handle fatal errors.

What we want to have happen,

1. is to have the fatal error captured,

2. logged to our processing table,

3. then have the function & psql exit with a non-zero return code, informing Informatica of the process failure.

I'm having several problems.

1. Under GP, any function called from psql is committed as a single transaction. I can handle the sql exception, and log the error to the table, and return a non-zero return code to psql.

2. I don't know how to raise exception in the psql script. All I can imagine is to nest the function calls, having the outer function issue raise exception - but then the entire transaction is rolled back since the transactions are nested. so I loose the logging messages.

3. I'd like to have psql capture the return value and provide to a 2nd function which would then raise exeception. But don't know and can't tell from the doc if I can assign function output to psql metavariables.

4. Don't know how to do anything with the psql metavariable ie if :last_return_code >= 16 then raise exception.

Suggestions would be appreciated.
Thanks

Doug Little

Responses

Browse pgsql-general by date

  From Date Subject
Next Message felix 2012-06-20 14:00:26 Re: Feature discussion: Should syntax errors abort a transaction?
Previous Message Greg Sabino Mullane 2012-06-20 13:46:33 Re: Feature discussion: Should syntax errors abort a transaction?