From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | "Fernando Papa" <fpapa(at)claxson(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Catching errors in pl/pgsql |
Date: | 2003-03-14 15:16:55 |
Message-ID: | 200303141516.55371.dev@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Friday 14 Mar 2003 2:20 pm, Fernando Papa wrote:
> Hi everybody!
>
> I'm migrating severals application from Oracle to PostgreSQL. I read all
> the documents about PL/PGSQL and how porting from oracle to pg. I ported
> several procedures succesful, but I have a lot of problems "translating"
> this kind of code:
> (...)
> EXCEPTION
> WHEN DUP_VAL_ON_INDEX THEN
> V_Error := 'PR_INSERT_VIOLATION_PK';
> How I can catch the error, for example, if I try to insert a duplicate
> value on primary key? or if parent keys not found? I need to catch the
> error inside the pl/pgsql function and then pass a message to
> application. I will rise a exception (I know how to do this) but I don't
> know how to identify the errors...
You can't at the moment. There's no way to catch an error inside a function -
an error aborts the current transaction without you being able to catch it.
I'm afraid you're going to have to check for whatever causes the error and
avoid it instead.
--
Richard Huxton
From | Date | Subject | |
---|---|---|---|
Next Message | Doug McNaught | 2003-03-14 15:24:15 | Re: Is a limitation for the number of large objects that can be stored in a PostgreSQL database? |
Previous Message | Tom Lane | 2003-03-14 15:16:40 | Re: constant scalar subselect no longer equivalent to constant? |