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.

Reply via email to