last inserted raw (identity)

From: b b <hell_wild_hot2(at)yahoo(dot)com>
To: postgresql <pgsql-general(at)postgresql(dot)org>
Subject: last inserted raw (identity)
Date: 2003-08-01 23:25:05
Message-ID: 20030801232505.69498.qmail@web41804.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Is there an environment variable that returns the
primary key of the last inserted row. This is usefull
if you insert a rwo and need the primary key to insert
it into another table as a foreign key.

In MS-SQL that is equivalent to @@identity variable:
insert into organization ('org name', ....)
insert into contact (@@identity, 'contact name'
.....)
Here Identity is the organization's ID that is needed
as a foreign key in contact table.

Cheers.

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2003-08-01 23:55:05 Re: How to do?
Previous Message Jonathan Bartlett 2003-08-01 22:55:45 Re: Apache - DBI - Postgresql: Cancelling queries