function execution problem - plpgsql

From: "Zoltan Bartko" <silvanus(at)azet(dot)sk>
To:
Subject: function execution problem - plpgsql
Date: 2005-07-21 08:18:05
Message-ID: 20050721081806.19136.qmail@ems003.blast.sk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello folks

I would like to ask the following thing:

I have two functions: funcA() drops a row from table A, funcB() drops a
row from table B that references table A. funcA() calls funcB() and
issues a delete command after returning from funcB(). I get an error,
stating that it can not be done, because there is a row in B that can
not be deleted with deleting the particular row from A.

So now: Why does this happen? Is it because a function is a transaction?
why do series of update/delete operations work fine in a single
function, but fail as soon as one of these operations is performed by
function? Is there any way to avoid this behavior?

My functions return values, error codes infact, so I need the return
values, because I do not allow the users to directly insert, update or
delete records in the tables, only via functions.

I could define a trigger that fires before deleting the row from table A
and calls funcB(), raises an exception if anything happened, catch the
exception if funcA(), if the return value was not correct, but with this
approach I loose the error value, because in PgSQL 8.0 there is no
SQLERRM I could analyse.

Please enlighten me

Thanks

Zoltan

__________________________________________________
http://www.email.azet.sk - 2 000 MB na Vase e-maily!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ezequiel Tolnay 2005-07-21 09:10:03 Re: Wishlist?
Previous Message vinita bansal 2005-07-21 07:43:06 Re: RAMFS with Postgres