SQL Help - Obtaining ID of record INSERTED

From: "josh(at)segrestfarms(dot)com" <josh(at)segrestfarms(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: SQL Help - Obtaining ID of record INSERTED
Date: 2005-08-16 21:09:04
Message-ID: 430255F0.7060500@segrestfarms.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Greetings.

INSERT INTO
orderstemp (customerid,datecreated)
VALUES
('5443','8/16/2005 12:00PM')

The table orderstemp has a unique identifier field, orderid (of type
SERIAL).

How can I obtain the orderid of the record inserted in the INSERT INTO
statement in postgresql?

MSSQL does it like this:

INSERT INTO
orderstemp (customerid,datecreated)
VALUES
('5443','8/16/2005 12:00PM')
SELECT @@identity as orderid

but this doens't work in postgresql.

Any ideas? Thanks in advance.

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Juan Miguel Paredes 2005-08-16 21:35:25 Re: SQL Help - Obtaining ID of record INSERTED
Previous Message Bruno Wolff III 2005-08-16 21:07:01 Re: Is there anyway to create a functional index using to_date?