X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 3681D9FA5DD for ; Fri, 23 Jun 2006 09:37:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 05561-01 for ; Fri, 23 Jun 2006 09:37:40 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from pd6mo2no.prod.shaw.ca (idcmail-mo2no.cg.shawcable.net [64.59.134.9]) by postgresql.org (Postfix) with ESMTP id B251D9FA182 for ; Fri, 23 Jun 2006 09:37:40 -0300 (ADT) Received: from pd8mr4no.prod.shaw.ca (pd8mr4no-qfe2.prod.shaw.ca [10.0.144.161]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0J1B00GRDCEQD2F0@l-daemon> for pgsql-sql@postgresql.org; Fri, 23 Jun 2006 06:37:38 -0600 (MDT) Received: from pn7ml4no.prod.shaw.ca ([10.0.149.113]) by pd8mr4no.prod.shaw.ca (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0J1B00L9FCEQXK90@pd8mr4no.prod.shaw.ca> for pgsql-sql@postgresql.org; Fri, 23 Jun 2006 06:37:38 -0600 (MDT) Received: from Dell4500 ([24.77.157.242]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with SMTP id <0J1B0090XCEI5I70@l-daemon> for pgsql-sql@postgresql.org; Fri, 23 Jun 2006 06:37:38 -0600 (MDT) Date: Fri, 23 Jun 2006 07:37:41 -0500 From: George Weaver Subject: Re: Fwd: Start up question about triggers To: "Forums @ Existanze" Cc: pgsql-sql@postgresql.org Message-id: <006901c696c1$d2af82d0$6400a8c0@Dell4500> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-Mailer: Microsoft Outlook Express 6.00.2900.2869 Content-type: text/plain; format=flowed; charset=iso-8859-1; reply-type=original Content-transfer-encoding: 7bit X-Priority: 3 X-MSMail-priority: Normal References: <200606230715.k5N7FHjO007409@auth-smtp.hol.gr> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/257 X-Sequence-Number: 25493 Hi Fotis, If you end up having to create a solution for each of the 80 tables, you may want to check out the following (may also give you addtional ideas for what you're trying to achieve): http://www.varlena.com/GeneralBits/104.php (Logging Audit Changes with Composite Typed Columns). Regards, George ----- Original Message ----- From: "Forums @ Existanze" To: Sent: Friday, June 23, 2006 2:15 AM Subject: Re: Fwd: [SQL] Start up question about triggers > > Hello again aaron, > > Im really interested in the part where you say "generic trigger" can you > give me some tips? As to how I will go about that? I had already read the > links that Richard gave, I new I could get the values like that. So right > now I will have to create a trigger for each of my tables to create the > necessary queries, or I could do it "generically" :-) > > Best Regards, > Fotis > >> -----Original Message----- >> From: pgsql-sql-owner@postgresql.org >> [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Richard >> Broersma Jr >> Sent: 23 June 2006 08:10 >> To: Aaron Bono; pgsql-sql@postgresql.org >> Subject: Re: Fwd: [SQL] Start up question about triggers >> >> > I did some research and can't even find a way to get meta >> data in a trigger. >> > >> > In a trigger, is there a way to inspect OLD and NEW to see what >> > columns are there and see what has changed? If so, you may not be >> > able to grab the actual query but you could create a >> generic trigger >> > that reconstructs a possible update/insert/delete for any >> table in your database. >> > >> > Does anyone know of a good place to go get information about using >> > meta data in a stored procedure or trigger? >> >> yes. >> See the section "User Comments" at the very bottom of Chapter >> 33 after "Writing Trigger Functions in C". It is odd that a >> PL_PGSQL example is given at the end a chapter for triggers >> written in C. >> >> http://www.postgresql.org/docs/8.1/interactive/trigger-example.html >> >> Also see the entire chapter 36.10 "Trigger Procedures" >> http://www.postgresql.org/docs/8.1/interactive/plpgsql-trigger.html >> >> Hope this is what you are looking for. >> >> Regards, >> >> Richard Broersma Jr. >> >> ---------------------------(end of >> broadcast)--------------------------- >> TIP 9: In versions below 8.0, the planner will ignore your desire to >> choose an index scan if your joining column's datatypes do not >> match >> > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org >