pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
new.oid not working inside rule [repost]
2+ messages / 2 participants
[nested] [flat]

* new.oid not working inside rule [repost]
@ 1999-08-14 04:05 Michael Olivier <mo@local2me.com>
  1999-08-16 08:10 ` Re: [SQL] new.oid not working inside rule [repost] Jan Wieck <wieck@debis.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Michael Olivier @ 1999-08-14 04:05 UTC (permalink / raw)
  To: pgsql-sql

I am reposting this because I haven't gotten an answer... is anyone
successfully using new.oid within a rule to store the oid of an inserted
row into another table?  (See below)

This is in 6.4.2-3.

thanks,
--Michael


Michael Olivier wrote:
> 
> 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [SQL] new.oid not working inside rule [repost]
  1999-08-14 04:05 new.oid not working inside rule [repost] Michael Olivier <mo@local2me.com>
@ 1999-08-16 08:10 ` Jan Wieck <wieck@debis.com>
  0 siblings, 0 replies; 2+ messages in thread

From: wieck@debis.com @ 1999-08-16 08:10 UTC (permalink / raw)
  To: mo@local2me.com; +Cc: pgsql-sql

>
> I am reposting this because I haven't gotten an answer... is anyone
> successfully using new.oid within a rule to store the oid of an inserted
> row into another table?  (See below)
>
> This is in 6.4.2-3.

    It cannot work - sorry.

    This  is because of the way rules are executed. If you have a
    rule on INSERT, this rules action is executed  prior  to  the
    INSERT  itself  and  will do mainly the same scans to collect
    the  data  that  will   be   inserted   (in   the   case   of
    INSERT...SELECT...). At this time, the OID's which will later
    get assigned aren't known.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#========================================= wieck@debis.com (Jan Wieck) #





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~1999-08-16 08:10 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-08-14 04:05 new.oid not working inside rule [repost] Michael Olivier <mo@local2me.com>
1999-08-16 08:10 ` Jan Wieck <wieck@debis.com>

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