X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0D3C05283C for ; Tue, 16 Aug 2005 19:06:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16186-08 for ; Tue, 16 Aug 2005 22:06:04 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id 02E6C52803 for ; Tue, 16 Aug 2005 19:06:03 -0300 (ADT) Received: from [192.168.1.55] (fc1smp [66.93.38.87]) (authenticated bits=0) by hosting.commandprompt.com (8.13.4/8.13.4) with ESMTP id j7GM4YTS029732; Tue, 16 Aug 2005 15:04:34 -0700 Message-ID: <430263EF.6000302@commandprompt.com> Date: Tue, 16 Aug 2005 15:08:47 -0700 From: "Joshua D. Drake" Organization: Command Prompt, Inc. User-Agent: Mozilla Thunderbird 1.0.6-1.1.fc4 (X11/20050720) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "josh@segrestfarms.com" Cc: pgsql-admin@postgresql.org Subject: Re: SQL Help - Obtaining ID of record INSERTED References: <430255F0.7060500@segrestfarms.com> In-Reply-To: <430255F0.7060500@segrestfarms.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by milter-greylist-1.6 (hosting.commandprompt.com [192.168.1.101]); Tue, 16 Aug 2005 15:04:34 -0700 (PDT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.248 required=5 tests=[AWL=-0.222, TO_ADDRESS_EQ_REAL=0.47] X-Spam-Level: X-Archive-Number: 200508/201 X-Sequence-Number: 18520 josh@segrestfarms.com wrote: > 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 If you are in the same session you can do: select currval('sequencename_of_orderid'); > > but this doens't work in postgresql. > > Any ideas? Thanks in advance. > > ---------------------------(end of broadcast)--------------------------- > TIP 1: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly -- Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240 PostgreSQL Replication, Consulting, Custom Programming, 24x7 support Managed Services, Shared and Dedicated Hosting Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/