pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Obtaining the primary key of the record just inserted
3+ messages / 2 participants
[nested] [flat]

* Obtaining the primary key of the record just inserted
@ 2007-11-08 17:56  Oliveiros Cristina <oliveiros.cristina@marktest.pt>
  0 siblings, 1 reply; 3+ messages in thread

From: Oliveiros Cristina @ 2007-11-08 17:56 UTC (permalink / raw)
  To: pgsql-sql

 
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() ; ?

Any help deeply appreciated

Best,
Oliveiros

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Obtaining the primary key of the record just inserted
@ 2007-11-08 18:03  Scott Marlowe <scott.marlowe@gmail.com>
  parent: Oliveiros Cristina <oliveiros.cristina@marktest.pt>
  0 siblings, 1 reply; 3+ messages in thread

From: Scott Marlowe @ 2007-11-08 18:03 UTC (permalink / raw)
  To: Oliveiros Cristina <oliveiros.cristina@marktest.pt>; +Cc: pgsql-sql

On Nov 8, 2007 11:56 AM, Oliveiros Cristina
<oliveiros.cristina@marktest.pt> 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;



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Obtaining the primary key of the record just inserted
@ 2007-11-08 19:10  Oliveiros Cristina <oliveiros.cristina@marktest.pt>
  parent: Scott Marlowe <scott.marlowe@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Oliveiros Cristina @ 2007-11-08 19:10 UTC (permalink / raw)
  To: Scott Marlowe <scott.marlowe@gmail.com>; +Cc: pgsql-sql

It worked perfectly.
Thanks a million, Scott.

Best,
Oliveiros
----- Original Message ----- 
From: "Scott Marlowe" <scott.marlowe@gmail.com>
To: "Oliveiros Cristina" <oliveiros.cristina@marktest.pt>
Cc: <pgsql-sql@postgresql.org>
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
> <oliveiros.cristina@marktest.pt> 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;
>



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2007-11-08 19:10 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-11-08 17:56 Obtaining the primary key of the record just inserted Oliveiros Cristina <oliveiros.cristina@marktest.pt>
2007-11-08 18:03 ` Scott Marlowe <scott.marlowe@gmail.com>
2007-11-08 19:10   ` Oliveiros Cristina <oliveiros.cristina@marktest.pt>

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