Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id B30B62E00E7 for ; Thu, 21 Feb 2008 19:49:48 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 07479-07 for ; Thu, 21 Feb 2008 19:49:46 -0400 (AST) Received: from acrmail.acceso.com.pe (unknown [190.81.51.227]) by postgresql.org (Postfix) with ESMTP id BC2452E00C2 for ; Thu, 21 Feb 2008 19:49:45 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by acrmail.acceso.com.pe (Postfix) with ESMTP id BBE015B0B54; Thu, 21 Feb 2008 18:49:41 -0500 (PET) Received: from acrmail.acceso.com.pe ([127.0.0.1]) by localhost (acrmail.acceso.com.pe [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4Rqg61rFZUPo; Thu, 21 Feb 2008 18:49:40 -0500 (PET) Received: from acceso.com.pe (localhost [127.0.0.1]) by acrmail.acceso.com.pe (Postfix) with ESMTP id 9A9005B0B4A; Thu, 21 Feb 2008 18:49:40 -0500 (PET) From: "dguevara" To: Decibel! Cc: pgsql-admin@postgresql.org Subject: Re: Trigger from a function Date: Thu, 21 Feb 2008 18:49:40 -0500 Message-Id: <20080221234117.M29958@acceso.com.pe> In-Reply-To: <290D84E7-AD9F-45A2-AC4C-F20DAF8238FE@decibel.org> References: <20080218161525.M66419@acceso.com.pe> <290D84E7-AD9F-45A2-AC4C-F20DAF8238FE@decibel.org> X-Mailer: OpenWebMail 2.52 20060502 X-OriginatingIP: 192.168.2.11 (dguevara) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.1 tagged_above=0 required=5 tests=RDNS_NONE=0.1 X-Spam-Level: X-Archive-Number: 200802/260 X-Sequence-Number: 28334 Thanks for your response, i made a mistake, the last function is like this: CREATE OR REPLACE FUNCTION Z RETURNS "trigger" AS $BODY$ begin if (tg_op in ('INSERT', 'UPDATE', 'DELETE')) then update B; end if; $BODY$ LANGUAGE 'plpgsql' VOLATILE; And the reason why i made a fake example is because it basically is that, a simple function with a simple update. I'd just like to know why if i do that update through a query it invokes the trigger and not when i do it inside the function. Danilo Guevara Departamento de Sistemas Acceso Crediticio SAC ---------- Original Message ----------- From: Decibel! To: dguevara Cc: pgsql-admin@postgresql.org Sent: Thu, 21 Feb 2008 17:31:44 -0600 Subject: Re: [ADMIN] Trigger from a function > 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 ------- End of Original Message -------