function within a function/rollbacks/exception handling

From: Lori Corbani <Lori(dot)Corbani(at)jax(dot)org>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: function within a function/rollbacks/exception handling
Date: 2011-11-07 19:18:12
Message-ID: 4542636FF9185340AC1FDDE71BF1992B1F7D11A5@jaxbhexms01.jax.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


I have a function, call it 'functionMain'. And I have several tables that each have trigger functions. Each trigger function needs to call 'functionMain' (with different parameters).

table A => trigger function A ==> functionMain
table B => trigger function B ==> functionMain
table C => trigger function C ==> functionMain

'functionMain' returns VOID (runs an insert statement). and has an exception/raise exception block.

An insert transaction for table A is launched (insertA), trigger function A is called,
'functionMain' is called and 'functionMain' fails. Hence, trigger function A needs to rollback.

Questions:

a) I am assuming that the trigger functions should use 'PERFORM functionMain(....)'?

b) if 'functionMain' fails, then 'funtionMain' automatically performs an implicit rollback, correct?

c) if 'functionMain' fails, should the trigger function also contain an exception handler
or will the rollback from 'functionMain' cascade up to the original transaction (insertA)?

Thanks.
Lori

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Devrim GÜNDÜZ 2011-11-07 19:22:23 Re: Is *.projects.postgresql.org offline?
Previous Message Leonardo Carneiro 2011-11-07 19:10:22 Is *.projects.postgresql.org offline?