pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aaron Bono <postgresql@aranya.com>
To: Forums @ Existanze <forums@existanze.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Start up question about triggers
Date: Thu, 22 Jun 2006 11:03:17 -0500
Message-ID: <bf05e51c0606220903v3ece4130ufa191d936266494c@mail.gmail.com> (raw)
In-Reply-To: <200606221309.k5MD90S3007695@auth-smtp.hol.gr>
References: <200606220918.k5M9IuAs001850@auth-smtp.hol.gr>
	<200606221309.k5MD90S3007695@auth-smtp.hol.gr>

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
>

view thread (29+ messages)  latest in thread

Message-ID: <bf05e51c0606220903v3ece4130ufa191d936266494c@mail.gmail.com>
Permalink:  ../bf05e51c0606220903v3ece4130ufa191d936266494c@mail.gmail.com/
Also on:    postgresql.org/message-id/bf05e51c0606220903v3ece4130ufa191d936266494c@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: postgresql@aranya.com, forums@existanze.com
  Subject: Re: Start up question about triggers
  In-Reply-To: <bf05e51c0606220903v3ece4130ufa191d936266494c@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox