pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Decibel! <decibel@decibel.org>
To: dguevara <dguevara@acceso.com.pe>
Cc: pgsql-admin@postgresql.org
Subject: Re: Trigger from a function
Date: Thu, 21 Feb 2008 17:31:44 -0600
Message-ID: <290D84E7-AD9F-45A2-AC4C-F20DAF8238FE@decibel.org> (raw)
In-Reply-To: <20080218161525.M66419@acceso.com.pe>
References: <20080218161525.M66419@acceso.com.pe>

On Feb 18, 2008, at 10:29 AM, dguevara wrote:

> Hello all,
>
> I have a problem with a trigger which is executed when i make an  
> UPDATE trought a simple query, but
> not when the UPDATE is made in a store procedure.
>
> Maybe i'm missing something in the declaration of the function and  
> i would appreciate any help.
> T
> his is the function:
>
> CREATE OR REPLACE FUNCTION X
>   RETURNS SETOF void AS
> $BODY$
>
> begin
>   update A;
> end;
> $BODY$
>   LANGUAGE 'plpgsql' VOLATILE;
>
>
> The trigger:
>
> CREATE TRIGGER Y
>   BEFORE INSERT OR UPDATE
>   ON A
>   FOR EACH ROW
>   EXECUTE PROCEDURE Z;
>
> CREATE OR REPLACE FUNCTION Z
>   RETURNS "trigger" AS
> $BODY$
> begin
>      if (tg_op in ('INSERT', 'UPDATE', 'DELETE')) then
>         update A;
>      end if;
> $BODY$
>   LANGUAGE 'plpgsql' VOLATILE;

Can't help much with your fake example, but I am wondering why you  
have a recursive trigger on A.
-- 
Decibel!, aka Jim C. Nasby, Database Architect  decibel@decibel.org
Give your computer some brain candy! www.distributed.net Team #1828

Attachments:

  smime.p7s (application/pkcs7-signature, 2.5K) download

view thread (3+ messages)  latest in thread

Message-ID: <290D84E7-AD9F-45A2-AC4C-F20DAF8238FE@decibel.org>
Permalink:  ../290D84E7-AD9F-45A2-AC4C-F20DAF8238FE@decibel.org/
Also on:    postgresql.org/message-id/290D84E7-AD9F-45A2-AC4C-F20DAF8238FE@decibel.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: decibel@decibel.org, dguevara@acceso.com.pe
  Subject: Re: Trigger from a function
  In-Reply-To: <290D84E7-AD9F-45A2-AC4C-F20DAF8238FE@decibel.org>
  References: <20080218161525.M66419@acceso.com.pe> <290D84E7-AD9F-45A2-AC4C-F20DAF8238FE@decibel.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox