pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: Di Croce, Tony <tdicroce@pelco.com>
Cc: 'pgsql-admin@postgresql.org' <pgsql-admin@postgresql.org>
Subject: Re: Stamping rows...
Date: Sun, 21 Nov 2004 18:56:12 -0700
Message-ID: <20041122015612.GA42649@winnie.fuhr.org> (raw)
In-Reply-To: <B2CC0E0F2C10D511B86600B0D06898420EA053DE@NETSRVR1.pelco.org>
References: <B2CC0E0F2C10D511B86600B0D06898420EA053DE@NETSRVR1.pelco.org>

On Thu, Nov 18, 2004 at 04:23:50PM -0800, Di Croce, Tony wrote:
> I am trying to find a way to stamp all of the rows affected by an update (or
> insert) with a unique value.

[snip]

> At first I tried to do this as a trigger function. The problem with this
> solution is that if I dont have the function called for each row, I cannot
> modify those rows. if I DO have the function called for each row, how do
> they get the "change_number" they cannot simply call nextval() as it will be
> different for each row (they also couldn't call curval() because then who is
> ever calling nextval()?)

Have you tried calling nextval() in a FOR EACH STATEMENT trigger
and currval() in a FOR EACH ROW trigger?  This works for me in
simple tests.  I don't know if statement triggers are guaranteed
to fire before row triggers, but they do appear to work that way.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



view thread (4+ messages)  latest in thread

Message-ID: <20041122015612.GA42649@winnie.fuhr.org>
Permalink:  ../20041122015612.GA42649@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20041122015612.GA42649@winnie.fuhr.org

 · 

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-admin@postgresql.org
  Cc: mike@fuhr.org, tdicroce@pelco.com
  Subject: Re: Stamping rows...
  In-Reply-To: <20041122015612.GA42649@winnie.fuhr.org>
  References: <B2CC0E0F2C10D511B86600B0D06898420EA053DE@NETSRVR1.pelco.org> <20041122015612.GA42649@winnie.fuhr.org>

* 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