Re: Question reagarding serial type. - Mailing list pgsql-general

From Dustin Sallings
Subject Re: Question reagarding serial type.
Date
Msg-id Pine.NEB.4.10.10006132118020.284-100000@foo.west.spy.net
Whole thread Raw
In response to Question reagarding serial type.  ("Mirko Geffken" <mgeffken@corcoranweb.com>)
List pgsql-general
On Thu, 8 Jun 2000, Mirko Geffken wrote:

# i have tried to find info elsewhere, but did not find anything to my
# satisfaction, so I was wondering if anyone on this list could point me
# into the right direction.
#
# When I create a table
#
# e.g.:
# create table xyz
# (
#   id    serial PRIMARY KEY,
#   uvw   varchar2(100)
# );
#
# I would like to get the id returned when I insert into this table. In
# oracle it is possible to do this: insert into xyz(uvw) values ('Test')
# returning id;

    What if you had two serials?  I guess that's not terribly likely.

# How can I do this with SQL in Postgres. Any ideas.

insert into xyz(uvw) values ('Test');
INSERT 18968479 1
dustin=# select currval('xyz_id_seq');
 currval
---------
       1
(1 row)


--
dustin sallings                            The world is watching America,
http://2852210114/~dustin/                 and America is watching TV.


pgsql-general by date:

Previous
From: "Marc Gehling"
Date:
Subject: pg_dump error: cache lookup failed
Next
From: selkovjr@mcs.anl.gov
Date:
Subject: Re: Size Limit