Re: [GENERAL] using ID as a key

From: <kaiq(at)realtyideas(dot)com>
To: "Ross J(dot) Reedstrom" <reedstrm(at)wallace(dot)ece(dot)rice(dot)edu>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] using ID as a key
Date: 2000-02-07 21:34:35
Message-ID: Pine.LNX.4.10.10002071532490.22529-100000@picasso.realtyideas.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)realtyideas(dot)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(at)rice(dot)edu>
> NSBRI Research Scientist/Programmer
> Computer and Information Technology Institute
> Rice University, 6100 S. Main St., Houston, TX 77005
>
>
> ************
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lars 2000-02-08 00:54:48 SubSelect as a column
Previous Message Ross J. Reedstrom 2000-02-07 20:10:08 Re: [GENERAL] using ID as a key