pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Olivier <mo@local2me.com>
To: pgsql-sql@postgreSQL.org <pgsql-sql@postgreSQL.org>
Subject: few questions about rules: timestamp, new.oid
Date: Mon, 02 Aug 1999 14:04:58 -0700
Message-ID: <37A607FA.E9727ABD@local2me.com> (raw)

Hi,

I am setting up rules to track changes to some tables, in PG 6.4.2-3 (RH
Linux 6.0) ... and have two questions:


1. I'm storing a datetime timestamp for when the change was entered into
my changes table, but the timestamp doesn't change with subsequent
tests:

    create rule users_modify_rule as on update to users do
        insert into changes (table_name, change_time, ref_oid, type)
        values ('users', 'now', current.oid, 'update');

dmtest=> select * from changes;
table_name|change_time                 |ref_oid|ref_name|type  
----------+----------------------------+-------+--------+------
users     |Mon Aug 02 13:52:34 1999 PDT| 990398|        |update
users     |Mon Aug 02 13:52:34 1999 PDT| 990398|        |update
users     |Mon Aug 02 13:52:34 1999 PDT| 990398|        |update
users     |Mon Aug 02 13:52:34 1999 PDT| 990398|        |update
users     |Mon Aug 02 13:52:34 1999 PDT| 990398|        |update
(5 rows)


2. How can I get the oid of a record being inserted?  Using new.oid
isn't getting it for me... the field in my changes table remains
blank...

    create rule users_add_rule as on insert to users do
        insert into changes (table_name, change_time, ref_oid, type)
        values ('users', 'now', new.oid, 'insert');

Getting some other field, like new.acctname, does work...


Thanks,
Michael



view thread (2+ messages)  latest in thread

Message-ID: <37A607FA.E9727ABD@local2me.com>
Permalink:  ../37A607FA.E9727ABD@local2me.com/
Also on:    postgresql.org/message-id/37A607FA.E9727ABD@local2me.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: mo@local2me.com
  Subject: Re: few questions about rules: timestamp, new.oid
  In-Reply-To: <37A607FA.E9727ABD@local2me.com>
  References: <37A607FA.E9727ABD@local2me.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