Re: [GENERAL] using ID as a key - Mailing list pgsql-general

From
Subject Re: [GENERAL] using ID as a key
Date
Msg-id Pine.LNX.4.10.10002071532490.22529-100000@picasso.realtyideas.com
Whole thread Raw
In response to Re: [GENERAL] using ID as a key  ("Ross J. Reedstrom" <reedstrm@wallace.ece.rice.edu>)
List pgsql-general
either way, I do not think it's "programmatic", I assume
nobody think they are?

On Mon, 7 Feb 2000, Ross J. Reedstrom wrote:

> On Mon, Feb 07, 2000 at 01:37:21PM -0600, Ed Loehr wrote:
> > kaiq@realtyideas.com wrote:
> > >
> > > and, it seems not "programmatically at all.
> >
> > What would make it "programmatic" in my view would be calling a
> > function, as in "$newID = GetNewID()", prior to INSERT and then using
> > the returned ID value in your INSERT, rather than using a 'default
> > nextval' to get the value.  I don't see why one wouldn't want to use a
> > sequence object within GetNewID(), FWIW.  But sounds like it is not
> > the kind of programmatic example/explanation you were looking for...
> >
>
> In fact, that's exactly how a number of core psql developers recommend
> handling the problem of how to get the new value just assigned by
> a default nextval() clause: don't use the default, do:
>
> $newID = SELECT nextval('my_ID_seq')
>
> INSERT INTO my_table (my_id,somethng,otherthng) VALUES ($newID, $some, $other)
>
> or equivalent, so you've already got the ID in hand.
>
> Personally, I use the SELECT curval('seq_name') construct.
>
> Ross
>
> --
> Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu>
> NSBRI Research Scientist/Programmer
> Computer and Information Technology Institute
> Rice University, 6100 S. Main St.,  Houston, TX 77005
>
>
> ************
>


pgsql-general by date:

Previous
From: "Ross J. Reedstrom"
Date:
Subject: Re: [GENERAL] using ID as a key
Next
From: Marten Feldtmann
Date:
Subject: Re: [GENERAL] using ID as a key