Skip site navigation (1) Skip section navigation (2)

Re: Trigger Procedures question

From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Jean-Francois Leveque <leveque(at)webmails(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Trigger Procedures question
Date: 2001-07-03 13:46:56
Message-ID: 200107031346.f63DkuA21673@jupiter.us.greatbridge.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Jean-Francois Leveque wrote:
>
> I want to check something before
> a delete is made.
>
> I made a before delete trigger that
> calls a procedure.
>
> The procedure raises an exception
> when I don't want the delete to be
> made (I could also have returned NULL,
> but wouldn't have get much information
> from it).
>
>
> The question is :
> What do I return when I want the delete to be made ?
>
> If I return OLD (known when deleting), maybe that
> cancels the delete too.
>
> I don't have NEW (known only on insert/update).
>
> I couldn't find the answer in the docs.

    Returning  OLD  from  a  BEFORE  ROW trigger let's the delete
    happen - no "maybe" here.  On AFTER ROW triggers  it  doesn't
    matter  what  you  return, the delete happened already (well,
    RAISE EXCEPTION will rollback of course).


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck(at)Yahoo(dot)com #



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


In response to

pgsql-hackers by date

Next:From: Jean-Francois LevequeDate: 2001-07-03 13:59:01
Subject: Trigger Procedures question
Previous:From: Alex PilosovDate: 2001-07-03 13:30:49
Subject: Re: selecting from cursor

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group