pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: josh@segrestfarms.com <josh@segrestfarms.com>
To: pgsql-admin@postgresql.org
Subject: SQL Help - Obtaining ID of record INSERTED
Date: Tue, 16 Aug 2005 17:09:04 -0400
Message-ID: <430255F0.7060500@segrestfarms.com> (raw)

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.



view thread (9+ messages)  latest in thread

Message-ID: <430255F0.7060500@segrestfarms.com>
Permalink:  ../430255F0.7060500@segrestfarms.com/
Also on:    postgresql.org/message-id/430255F0.7060500@segrestfarms.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: josh@segrestfarms.com
  Subject: Re: SQL Help - Obtaining ID of record INSERTED
  In-Reply-To: <430255F0.7060500@segrestfarms.com>
  References: <430255F0.7060500@segrestfarms.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox