By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,660 Members | 1,267 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,660 IT Pros & Developers. It's quick & easy.

Trigger Question

P: n/a
Hi,

I have a simple question. I have been looking at the HTML docs for Postgres
version: PostgreSQL 7.2.3-RH on i686-pc-linux-gnu, compiled by GCC 2.96. I
need to know if it is necessary to RETURN NULL from a trigger function after
raising an exception with RAISE EXCEPTION. We are doing many different data
validations in a "BEFORE UPDATE OR INSERT" trigger and we have been raising
an exception with an error string such that the error comes back to the
X-Windows applicaton. I read that returning NULL prevents other triggers from
fireing but doesn't RAISE EXCEPTION abort the tranaction and cause all
processing to stop?

Thanks in advance for your help...
--
"The world we have created is a product of our thinking. It cannot be
changed without changing our thinking."

--Albert Einstein

Work: 1-336-372-6812
Cell: 1-336-363-4719
email: te***@esc1.com

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Raising an exception means the return statement is never reached, so never
executed, so not relevant. Just like exceptions in other languages.

Yes, an exception will abort the transaction and stop further processing.

You may still want to conditionally return NULL instead of NEW (or OLD) on
some trigger-invoked SPs, but that has nothing to do with exceptions (the 2
are mutually exclusive).

== Ezra Epstein
"Terry Lee Tucker" <te***@esc1.com> wrote in message
news:200401111713.54786.te***@esc1.com...
Hi,

I have a simple question. I have been looking at the HTML docs for Postgres
version: PostgreSQL 7.2.3-RH on i686-pc-linux-gnu, compiled by GCC 2.96. I
need to know if it is necessary to RETURN NULL from a trigger function after
raising an exception with RAISE EXCEPTION. We are doing many different data
validations in a "BEFORE UPDATE OR INSERT" trigger and we have been raising
an exception with an error string such that the error comes back to the
X-Windows applicaton. I read that returning NULL prevents other triggers
from
fireing but doesn't RAISE EXCEPTION abort the tranaction and cause all
processing to stop?

Thanks in advance for your help...
--
"The world we have created is a product of our thinking. It cannot be
changed without changing our thinking."

--Albert Einstein

Work: 1-336-372-6812
Cell: 1-336-363-4719
email: te***@esc1.com

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org
Nov 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.