Re: [GENERAL] Simple problem? - Mailing list pgsql-general

From Steve Wolfe
Subject Re: [GENERAL] Simple problem?
Date
Msg-id 002301bf852c$aa48dba0$85755ad1@iboats.com
Whole thread Raw
In response to Simple problem?  (Stan Jacobs <jacobs@jtek.com>)
List pgsql-general
> You can do a SELECT curval('sequence_name'); to get the value you were
just
> assigned without worrying about other people updating, as curval gets the
> current value within the current transaction (or within the current
> session, either way, it works.)

  Or, my prefered method, create the table like so..

create table MyTable
(
    MyField        int4 default nextval('SomeSequence'),

...
);

  That gives you the flexibility to select the nextval of the sequence and
insert it yourself (if you need it for further processing), or to simply
let the database take care of it for itself.

steve


pgsql-general by date:

Previous
From: Ed Loehr
Date:
Subject: Re: [GENERAL] How to configure PostgreSQL for PHP access & postgresadmin
Next
From: Chris Jones
Date:
Subject: database corruption?