Re: COMMAND_OK for PL/pgSQL? - Mailing list pgsql-general

From Darko Prenosil
Subject Re: COMMAND_OK for PL/pgSQL?
Date
Msg-id 200210271436.49851.darko.prenosil@finteh.hr
Whole thread Raw
In response to COMMAND_OK for PL/pgSQL?  (Ben <bench@silentmedia.com>)
Responses Re: COMMAND_OK for PL/pgSQL?  (Ben <bench@silentmedia.com>)
List 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@postgresql.org)


pgsql-general by date:

Previous
From: Terry Yapt
Date:
Subject: Operator to compare numeric and double precision
Next
From: "freenet"
Date:
Subject: ODBC