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 35B009FA92E for ; Thu, 22 Jun 2006 13:03:28 -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 03514-01 for ; Thu, 22 Jun 2006 13:03:18 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.196]) by postgresql.org (Postfix) with ESMTP id DAD329FA7BA for ; Thu, 22 Jun 2006 13:03:17 -0300 (ADT) Received: by wx-out-0102.google.com with SMTP id s13so337834wxc for ; Thu, 22 Jun 2006 09:03:17 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=tVczVJKUwExkp/d+to3aOYUWeXBdsXAKcweNw5PsduYP3nkvz+TnaVr8pvWhtXGjAGa1JGRu8Ull8ooUVZPcJzoG15Ec2nT/hVqGwqf6w2gHvXHOXiogJuJzXyKxRpxXC/TQgQGNckrhQw7wfnT9FViVG2XfcjQkv7LVUJJ3mAc= Received: by 10.70.103.17 with SMTP id a17mr3324163wxc; Thu, 22 Jun 2006 09:03:17 -0700 (PDT) Received: by 10.70.66.15 with HTTP; Thu, 22 Jun 2006 09:03:17 -0700 (PDT) Message-ID: Date: Thu, 22 Jun 2006 11:03:17 -0500 From: "Aaron Bono" To: "Forums @ Existanze" Subject: Re: Start up question about triggers Cc: pgsql-sql@postgresql.org In-Reply-To: <200606221309.k5MD90S3007695@auth-smtp.hol.gr> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_10149_20653731.1150992197025" References: <200606220918.k5M9IuAs001850@auth-smtp.hol.gr> <200606221309.k5MD90S3007695@auth-smtp.hol.gr> X-Google-Sender-Auth: 9939f1f4c4f12bc7 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/252 X-Sequence-Number: 25488 ------=_Part_10149_20653731.1150992197025 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Why not just create a history table and have the trigger copy the data out of the table into the history table with a time stamp of the change. Then you don't need the query. For example Table A a_id, a_value1, a_value2 Table A_hist a_id, a_dt, a_value1, a_value2 Then A_hist has a PK of a_id, a_dt This would also be a lot easier to see WHAT changed and WHEN. You can use the NEW.col and OLD.col to see the new and old values during inserts and updates. Of course, I don't know your need so this may not be achieving your goal. -Aaron Bono On 6/22/06, Forums @ Existanze wrote: > > Sorry This is the complete message > > Hello all, > > I know that this question may be really simple, but I have decided to ask > here due to fact that I don't know how to search for this on google or on > the docs. > > I created a trigger fuction which updates a specific row in some table A. > Is it possible to retain the query that was used to trigger the function. > For example > > Table A > query_row_id > query_row > > > > TABLE B > id > name > > > > > > If I create a trigger on table B that says that after the insert command > to write the query into table A. So if I do > > insert into B values(1,"Blah") > > this will trigger my trigger. Is there any way to get the "insert into B > values(1,"Blah")? At the moment I can see only the type of query that it is > (INSERT UPDATE DELETE) > > best regards, > Fotis > > ------------------------------ > *From:* pgsql-sql-owner@postgresql.org [mailto: > pgsql-sql-owner@postgresql.org] *On Behalf Of *Forums @ Existanze > *Sent:* 22 June 2006 12:19 > *To:* pgsql-sql@postgresql.org > *Subject:* [SQL] Start up question about triggers > > Hello all, > > I know that this question may be really simple, but I have decided to ask > here due to fact that I don't know how to search for this on google or on > the docs. > > I created a trigger fuction which updates a specific row in some table A. > Is it possible to retain the query that was used to trigger the function. > For example > > Table A > query_row_id > query_row > > > > TABLE B > id > name > ------=_Part_10149_20653731.1150992197025 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Why not just create a history table and have the trigger copy the data out of the table into the history table with a time stamp of the change.  Then you don't need the query.

For example
Table A
a_id,
a_value1,
a_value2

Table A_hist
a_id,
a_dt,
a_value1,
a_value2

Then A_hist has a PK of a_id, a_dt

This would also be a lot easier to see WHAT changed and WHEN.  You can use the NEW.col and OLD.col to see the new and old values during inserts and updates.

Of course, I don't know your need so this may not be achieving your goal.

-Aaron Bono

On 6/22/06, Forums @ Existanze <forums@existanze.com> wrote:
Sorry This is the complete message
 
Hello all,
 
I know that this question may be really simple, but I have decided to ask here due to fact that I don't know how to search for this on google or on the docs.
 
I created a trigger fuction which updates a specific row in some table A. Is it possible to retain the query that was used to trigger the function. For example
 
Table A
query_row_id
query_row
 
 
 
TABLE B
id
name
 
 
 
 
 
If I create a trigger on table B that says that after the insert command to write the query into  table A. So if I do
 
insert into B values(1,"Blah")
 
this will trigger my trigger. Is there any way to get the "insert into B values(1,"Blah")? At the moment I can see only the type of query that it is (INSERT UPDATE DELETE)
 
best regards,
Fotis


From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Forums @ Existanze
Sent: 22 June 2006 12:19
To: pgsql-sql@postgresql.org
Subject: [SQL] Start up question about triggers

Hello all,
 
I know that this question may be really simple, but I have decided to ask here due to fact that I don't know how to search for this on google or on the docs.
 
I created a trigger fuction which updates a specific row in some table A. Is it possible to retain the query that was used to trigger the function. For example
 
Table A
query_row_id
query_row
 
 
 
TABLE B
id
name

------=_Part_10149_20653731.1150992197025--