Skip site navigation (1) Skip section navigation (2)

Re: Question re: serial

From: Devrim GUNDUZ <devrim(at)gunduz(dot)org>
To: Michael Satterwhite <michael(at)weblore(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Question re: serial
Date: 2004-04-24 17:37:44
Message-ID: Pine.LNX.4.44.0404242035380.16587-100000@emo.org.tr (view raw or flat)
Thread:
Lists: pgsql-sql
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi,

On Sat, 24 Apr 2004, Michael Satterwhite wrote:

> I have a table with a primary key defined as serial unique. When I insert a
> row into the table, I need to get the value of that row back so that I can
> use it to link rows in another table to it. How do I do that in Postgresql? I
> know that I can define a sequence and insert the value manually, but is there
> a way to query the value of the most recently inserted serial column of a
> row?

See currval() and nextval() functions:

Regards,
- -- 
Devrim GUNDUZ	       
devrim(at)gunduz(dot)org				devrim(dot)gunduz(at)linux(dot)org(dot)tr 
			http://www.TDMSoft.com
			http://www.gunduz.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFAiqXrtl86P3SPfQ4RAsxkAKCQ9oL9Jo4a7VZwqyI4YU6L7i3nEACgv/wM
0ce7up3AVctCYyksk7OYIpY=
=8Hr5
-----END PGP SIGNATURE-----


In response to

pgsql-sql by date

Next:From: Bruno Wolff IIIDate: 2004-04-24 17:44:37
Subject: Re: Question re: serial
Previous:From: Michael SatterwhiteDate: 2004-04-24 17:24:03
Subject: Question re: serial

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group