Re: Object Relational, Foreign Keys and Triggers - Mailing list pgsql-general

From Tino Wildenhain
Subject Re: Object Relational, Foreign Keys and Triggers
Date
Msg-id 1106674555.4014.164.camel@Andrea.peacock.de
Whole thread Raw
In response to Re: Object Relational, Foreign Keys and Triggers  (Alex Turner <armtuk@gmail.com>)
List pgsql-general
Am Dienstag, den 25.01.2005, 08:36 -0500 schrieb Alex Turner:
> Actualy max() works just fine.  It's not the solution I use in the
> middle tier, but it works for a functional example.  both max() and
> currval() are bad because they can cause a race condition where the
> sequence has been incremented by another thread.  It's always better
> to get nextval('sequence') and store it in a local var, then use it in
> the main insert and corresponding sub-inserts.

No, thats wrong. If you read the documentation again on that matter, you
will see. currval() works on at least one nextval() in the connection
you are running and therefore keeps showing the last result of nextval()
in this very connection - no matter what other connections/sessions do.
Thats the whole point of sequences anyway.

HTH
Tino


pgsql-general by date:

Previous
From: "Thomas Chille (spoon)"
Date:
Subject: difficult JOIN
Next
From: Michael Fuhr
Date:
Subject: Re: Validating user-input to be inserted in regular expressions