Accessing insert values in triggers

From: Hasnul Fadhly bin Hasan <hasnulfadhly(dot)h(at)mimos(dot)my>
To: pgsql-performance(at)postgresql(dot)org, pgsql-novice(at)postgresql(dot)org
Subject: Accessing insert values in triggers
Date: 2005-02-02 10:02:28
Message-ID: 4200A534.3030405@mimos.my
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice pgsql-performance

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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Jeremiah Knoche 2005-02-02 10:53:53 Batch Insert tables
Previous Message William Dominguez 2005-02-02 08:22:16 some help

Browse pgsql-performance by date

  From Date Subject
Next Message Bruce Momjian 2005-02-02 15:54:50 Re: Swapping on Solaris
Previous Message Alex Turner 2005-02-02 04:47:31 Re: High end server and storage for a PostgreSQL OLTP system