Re: Insert and obtain the pk

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Eliu Montoya <eliu(at)itam(dot)mx>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Insert and obtain the pk
Date: 2003-11-06 18:52:05
Message-ID: Pine.LNX.4.44.0311061951290.29650-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Eliu Montoya writes:

> Does anyone know an easy way to insert a record (without a value for the
> primary key because it is a sequence) and at the same time obtain the value
> of primary key that was assign to this new record.

If you know the name of the sequence then you can use the function
currval() to get the last assigned value in your session.

--
Peter Eisentraut peter_e(at)gmx(dot)net

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Carlos Oliva 2003-11-06 19:00:36 Re: Install files for version 7.4
Previous Message Peter Eisentraut 2003-11-06 18:50:59 Re: Install files for version 7.4