Re: [GENERAL] How to get seq after insert]

From: Karl DeBisschop <kdebisschop(at)spaceheater(dot)infoplease(dot)com>
To: maillist(at)candle(dot)pha(dot)pa(dot)us
Cc: signal(at)shreve(dot)net, michael(dot)davis(at)tvguide(dot)com, pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] How to get seq after insert]
Date: 1999-04-15 12:56:58
Message-ID: 199904151256.IAA27305@skillet.infoplease.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Thu, 15 Apr 1999, Bruce Momjian wrote:

> > On Wed, 14 Apr 1999, Michael Davis wrote:
> >
> > > The safest way is to select the nextval('seq_name') and then insert using
> > > this value.
> >
> > I understand, I just thought something like, I do the insert, and then
> > grab the value with:
> >
> > $insertid = $sth->{'insertid'};
>
> The OID is returned from the insert. Use that, or use it to look up the
> field you want.

Actually, I think the number of rows inserted is returned from the
insert, or an error code (a negative number). But the OID can be
obtained by $oid = sth->{'pg_oid_status'};

--
Karl DeBisschop <kdebisschop(at)spaceheater(dot)infoplease(dot)com>
617.832.0332 (Fax: 617.956.2696)

Information Please - your source for FREE online reference
http://www.infoplease.com - Your Ultimate Fact Finder
http://kids.infoplease.com - The Great Homework Helper

In response to

Browse pgsql-general by date

  From Date Subject
Next Message darold 1999-04-15 14:50:29 The WWW of PostgreSQL
Previous Message The Hermit Hacker 1999-04-15 12:19:02 Re: [GENERAL] what is the max postgres db size & table size?