X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 077E08B9C21; Wed, 2 Feb 2005 10:02:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86958-01; Wed, 2 Feb 2005 10:02:34 +0000 (GMT) Received: from ew.mimos.my (ew.mimos.my [192.228.129.34]) by svr1.postgresql.org (Postfix) with ESMTP id 3B97E8B9C0C; Wed, 2 Feb 2005 10:02:35 +0000 (GMT) Received: from mimos.my (mcg189.nat.mimos.my [10.1.18.189]) by ew.mimos.my (8.12.9p2/8.12.9) with ESMTP id j12A2Xdp050568; Wed, 2 Feb 2005 18:02:33 +0800 (MYT) (envelope-from hasnulfadhly.h@mimos.my) Message-ID: <4200A534.3030405@mimos.my> Date: Wed, 02 Feb 2005 18:02:28 +0800 From: Hasnul Fadhly bin Hasan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org, pgsql-novice@postgresql.org Subject: Accessing insert values in triggers Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200502/21 X-Sequence-Number: 12260 Hi, I am trying to build a function that would extend the trigger in general tid bits that would only track count changes for table rows. The one i am trying to build would check which column and value should be tracked. e.g. below would be the tracker. CREATE TABLE "public"."aaaa" ( "tables" TEXT, "columns" TEXT[], "values" TEXT[], "counts" BIGINT ) WITH OIDS; The column array is the column name and the values array would be the values matching the columns array defined. if columns has {group,item} then values has {1,'basket'} so if the data inserted matches the values defined, it will be tracked. When new data is inserted, we have to use new.xxxx to access the data. Is there another way to access the data that would be more generic like value[1] and so on? This way, the tracker is independant of any tables. i believe tg_argv is only for data being updated. I'm have not done any functions in C, but for those who has, it is more possible to do it in C? If those who has used it say i can access the data easier in C, then i'll have to read up and learn it. I was looking through the examples in the doc on creating triggers in C. I believe the data i'm looking for is in tg_trigtuple but i am not sure how it is supposed to be accessed. Anyone knows of any links i can refer to or anyones has simple codes showing how to access the data? Thanks for any info. Hasnul