From oliveiros.cristina@marktest.pt Thu Nov 8 17:56:23 2007 Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 383A19F926D for ; Thu, 8 Nov 2007 13:56:23 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 40266-04-2 for ; Thu, 8 Nov 2007 13:56:16 -0400 (AST) Received: from jupiter.marktest.pt (delta.marktest.pt [80.251.174.116]) by postgresql.org (Postfix) with ESMTP id 8FA439FCB88 for ; Thu, 8 Nov 2007 13:56:16 -0400 (AST) Received: from suite (suite.marktest.pt [10.61.90.236]) by jupiter.marktest.pt with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id VG9WDHD9; Thu, 8 Nov 2007 17:56:14 -0000 Message-ID: <009901c82230$a799d3b0$ec5a3d0a@marktestcr.marktest.pt> From: "Oliveiros Cristina" To: Subject: Obtaining the primary key of the record just inserted Date: Thu, 8 Nov 2007 17:56:14 -0000 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0096_01C82230.A78BA2E0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.114 tagged_above=0 required=5 tests=AWL=0.112, BAYES_50=0.001, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200711/27 X-Sequence-Number: 29555 This is a multi-part message in MIME format. ------=_NextPart_000_0096_01C82230.A78BA2E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable =20 Hello, All, I have the need to know the primary key assigned to a record I've just = INSERTed .=20 Is there an easy way to solve this ? Similar to SQLServer's SELECT scope_identity() ; ? Any help deeply appreciated Best, Oliveiros ------=_NextPart_000_0096_01C82230.A78BA2E0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
 
Hello, All,
 
I have the need to know the primary key = assigned to=20 a record I've just INSERTed .=20
 
Is there an easy way to solve this = ?
 
Similar to SQLServer's  SELECT scope_identity() ; ?
 
Any help deeply = appreciated
 
Best,
Oliveiros
------=_NextPart_000_0096_01C82230.A78BA2E0-- From scott.marlowe@gmail.com Thu Nov 8 18:03:19 2007 Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 698479FCB9D for ; Thu, 8 Nov 2007 14:03:19 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 70856-02-8 for ; Thu, 8 Nov 2007 14:03:03 -0400 (AST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.173]) by postgresql.org (Postfix) with ESMTP id 9B5759FCB8F for ; Thu, 8 Nov 2007 14:03:02 -0400 (AST) Received: by ug-out-1314.google.com with SMTP id j3so409406ugf for ; Thu, 08 Nov 2007 10:03:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=wWVHMMN8D4BwnZExrtB+DxEw1O8VPsFDDAOB7m69mng=; b=RHznZb/6Mc8FY8AeqaDIjWhekAv2dLAI+w6IPJ9ARmKCeFF3GC4VXVbaUW9mZsxpXswNSB9lE+/kqzOJ/NdLTwOAQKAIH7doAKW6jRHIdaS8naCwS99Tvl9eLjaUDN4O6BfQSBW5fJWXUQgG8wvb/pmhxBJ7gYdwJ5ZlzJqQ7LA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=p0Elso38PJ57OobsDdUACGxSr1spJBrV2f3lKJCC+iTpyz3mjWLoPqfewzcD1xOvkx7mU0p7YYl1U9WMEu/3TX0QKPlT4fRIixQAP8AlfCkSjZ4RxFkPURbRQwDimGt7RE84xdZ9J9thT7io5JQdZ6XuI62G6eE5NzEJvN2IOBs= Received: by 10.67.122.10 with SMTP id z10mr27501ugm.1194544980632; Thu, 08 Nov 2007 10:03:00 -0800 (PST) Received: by 10.67.16.19 with HTTP; Thu, 8 Nov 2007 10:03:00 -0800 (PST) Message-ID: Date: Thu, 8 Nov 2007 12:03:00 -0600 From: "Scott Marlowe" To: "Oliveiros Cristina" Subject: Re: Obtaining the primary key of the record just inserted Cc: pgsql-sql@postgresql.org In-Reply-To: <009901c82230$a799d3b0$ec5a3d0a@marktestcr.marktest.pt> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <009901c82230$a799d3b0$ec5a3d0a@marktestcr.marktest.pt> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/28 X-Sequence-Number: 29556 On Nov 8, 2007 11:56 AM, Oliveiros Cristina wrote: > > Hello, All, > > I have the need to know the primary key assigned to a record I've just > INSERTed . > > Is there an easy way to solve this ? > > Similar to SQLServer's SELECT scope_identity() ; ? In 8.2 and up: insert into table a (info) values ('abc') returning id; From oliveiros.cristina@marktest.pt Thu Nov 8 19:10:53 2007 Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id A9B819FCB88 for ; Thu, 8 Nov 2007 15:10:53 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 41526-03 for ; Thu, 8 Nov 2007 15:10:44 -0400 (AST) Received: from jupiter.marktest.pt (delta.marktest.pt [80.251.174.116]) by postgresql.org (Postfix) with ESMTP id 5BACD9FCB86 for ; Thu, 8 Nov 2007 15:10:42 -0400 (AST) Received: from suite (suite.marktest.pt [10.61.90.236]) by jupiter.marktest.pt with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id VG9WDHHQ; Thu, 8 Nov 2007 19:10:41 -0000 Message-ID: <00c501c8223b$0dde0c90$ec5a3d0a@marktestcr.marktest.pt> From: "Oliveiros Cristina" To: "Scott Marlowe" Cc: References: <009901c82230$a799d3b0$ec5a3d0a@marktestcr.marktest.pt> Subject: Re: Obtaining the primary key of the record just inserted Date: Thu, 8 Nov 2007 19:10:41 -0000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.109 tagged_above=0 required=5 tests=AWL=0.107, BAYES_50=0.001, STOX_REPLY_TYPE=0.001 X-Spam-Level: X-Archive-Number: 200711/29 X-Sequence-Number: 29557 It worked perfectly. Thanks a million, Scott. Best, Oliveiros ----- Original Message ----- From: "Scott Marlowe" To: "Oliveiros Cristina" Cc: Sent: Thursday, November 08, 2007 6:03 PM Subject: Re: [SQL] Obtaining the primary key of the record just inserted > On Nov 8, 2007 11:56 AM, Oliveiros Cristina > wrote: >> >> Hello, All, >> >> I have the need to know the primary key assigned to a record I've just >> INSERTed . >> >> Is there an easy way to solve this ? >> >> Similar to SQLServer's SELECT scope_identity() ; ? > > In 8.2 and up: > > insert into table a (info) values ('abc') returning id; >