Re: COMMAND_OK for PL/pgSQL?

From: Ben <bench(at)silentmedia(dot)com>
To: Darko Prenosil <darko(dot)prenosil(at)finteh(dot)hr>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: COMMAND_OK for PL/pgSQL?
Date: 2002-10-27 19:00:35
Message-ID: Pine.LNX.4.44.0210271059480.16949-100000@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hmmm.... I guess what I was hoping was to be able to return specific error
codes in case the insert failed.

On Sun, 27 Oct 2002, Darko Prenosil wrote:

> On Saturday 26 October 2002 15:07, Ben wrote:
> > I'm just getting into writting stored procs with PL/pgSQL, and I'm having
> > a hard time finding a way to check the status of my commands. For
> > instance, I see that after an insert, I can get the RESULT_OID - but I'm
> > not sure this is a good way to check if the insert happened correctly and
> > didn't violate any constraints. If it is, how do I check that the oid
> > returned is valid?
> >
>
> I think, when referential integrity is violated, exception is raised
> automatically, transaction that PL/PSQL started is rolled back and
> exit from function occurs.
> If you check your data for example in "TRIGGER", and you
> find out that the data is invalid, all you have to do is "RAISE EXCEPTION".
> So if the insert is invalid, there is no need to check it again, because the
> line after that "INSERT" statement will never be executed.
> It is similar to THROW in C++, only there is only one "CATCH" statement,
> handled by server.
>
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 2: you can get off all lists at once with the unregister command
> > (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Garo Hussenjian 2002-10-27 21:49:27 Dump / restore question
Previous Message Darko Prenosil 2002-10-27 15:36:49 Re: COMMAND_OK for PL/pgSQL?