On Fri, 7 Oct 2005 08:24:22 +1000, Steve Baldwin wrote:

Hi Steve

> (Apologies for top-posting ...)

No problem. It's the norm in the mod_perl list, but still distresses some
people.

> In most cases there will be no difference, but it is possible for
> triggerbased logic to subsequently bump the value of a sequence.
> This means fetching seq.currval after the insert could give you a
> value higher than the one actually used in the insert.

Right, or another insert by another user before the call to currval.

Since I wrote all the code there are definitely no triggers (yet).

> What we do is have the primary key populated in a BEFORE INSERT
> trigger, and then (as suggested) use the RETURNING clause in the
> insert.  This is the only way to *guarantee* you are getting the
> correct value.

I assume this is calling nextval and then using that value in the insert.

> If you need more info, let me know and I will provide an example.

Yes, please. I've never used a trigger, and even if they are simple, I'd rather
not stuff things up.

Email directly as per below if you think that's appropriate.
--
Cheers
Ron Savage, [EMAIL PROTECTED] on 7/10/2005
http://savage.net.au/index.html
Let the record show: Microsoft is not an Australian company


Reply via email to