Getting Primary Key Value After Insert

From: "Adam" <adam(at)spatialsystems(dot)org>
To: "Postgres general mailing list" <pgsql-general(at)postgresql(dot)org>
Subject: Getting Primary Key Value After Insert
Date: 2006-07-09 04:28:42
Message-ID: 003e01c6a310$2916eb90$0200a8c0@PANASONIULSWMR
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm inserting data into two tables, the second table has a forigen key that
points to the primary key of the first table.

After I insert a row into the first table, I need to take the primary key
value created in "SERIAL" column and store it so I can insert it as the
forigen key value on the second table.

What is the best way to get the value of the primary key ( SERIAL data
type ) of the row I inserted?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adam 2006-07-09 05:00:31 Re: Getting Primary Key Value After Insert
Previous Message Joshua D. Drake 2006-07-09 03:12:37 Re: [GENERAL] UUID's as primary keys