Re: COMMAND_OK for PL/pgSQL?

From: Darko Prenosil <darko(dot)prenosil(at)finteh(dot)hr>
To: Ben <bench(at)silentmedia(dot)com>, "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: COMMAND_OK for PL/pgSQL?
Date: 2002-10-27 15:36:49
Message-ID: 200210271436.49851.darko.prenosil@finteh.hr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ben 2002-10-27 19:00:35 Re: COMMAND_OK for PL/pgSQL?
Previous Message Michael Walzl 2002-10-27 15:08:28 History in the postgres monitor