Re: Catch exceptions outside function

From: Roberto Grandi <roberto(dot)grandi(at)trovaprezzi(dot)it>
To: Igor Neyman <ineyman(at)perceptron(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Catch exceptions outside function
Date: 2013-09-18 15:12:01
Message-ID: 1419174490.399836.1379517121348.JavaMail.root@trovaprezzi.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Thanks Igor,

this is a sufficient idea to take into account for upgrading to 9.x release.
Thanks again.

Roberto

----- Messaggio originale -----
Da: "Igor Neyman" <ineyman(at)perceptron(dot)com>
A: "Roberto Grandi" <roberto(dot)grandi(at)trovaprezzi(dot)it>, pgsql-admin(at)postgresql(dot)org
Inviato: Mercoledì, 18 settembre 2013 15:37:12
Oggetto: RE: Catch exceptions outside function

> -----Original Message-----
> From: pgsql-admin-owner(at)postgresql(dot)org [mailto:pgsql-admin-
> owner(at)postgresql(dot)org] On Behalf Of Roberto Grandi
> Sent: Wednesday, September 18, 2013 6:17 AM
> To: pgsql-admin(at)postgresql(dot)org
> Subject: [ADMIN] Catch exceptions outside function
>
>
> Dear all
>
> I ask for your help cause I can't point out the solution to my problem on PG
> 8.3 I would catch an exception outside any function/procedure but directly
> within script.
>
>
> BEGIN;
>
> -- raise an exception code
>
> EXCEPTION
> WHEN 'exception_type'
> THEN ROLLBACK;
>
> COMMIT;
>
> is it possible with PG 8.3?
>
>
> Many thanks in advance.
>
> Roberto
>

No. It's not possible in 8.3.
What you want is basically anonymous plpgsql block, "EXCEPTION" - is plpgsql, not pure sql, could be used only inside plpgsql function in 8.3.

OTOH, starting with 9.0 you can use anonymous plpgsql blocks, and get what you asked for.

Regards,
Igor Neyman

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message David Johnston 2013-09-18 16:48:01 Re: Catch exceptions outside function
Previous Message Scott Ribe 2013-09-18 13:52:33 Re: Catch exceptions outside function