Re: Get the last inserted id
От | Nacef LABIDI |
---|---|
Тема | Re: Get the last inserted id |
Дата | |
Msg-id | f16f7ea00804111043t67ddf4b8gc18a9780ecaa47eb@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Get the last inserted id ("Scott Marlowe" <scott.marlowe@gmail.com>) |
Список | pgsql-sql |
Nice idea but how can I use this in a frontend that I am developing using Delphi and ADO objects ?
On Fri, Apr 11, 2008 at 7:41 PM, Scott Marlowe <scott.marlowe@gmail.com> wrote:
smarlowe=# create table test (a serial primary key, b text);On Fri, Apr 11, 2008 at 11:23 AM, Nacef LABIDI <nacef.l@gmail.com> wrote:
> Hi all,
>
> I was wondering if postgres can return the last ID inserted for a table
> which the primary key is autoincremented. I need to retrieve this ID in my
> code to continue processing on that inserted row.
NOTICE: CREATE TABLE will create implicit sequence "test_a_seq" for
serial column "test.a"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"test_pkey" for table "test"
CREATE TABLE
smarlowe=# insert into test (a,b) values (DEFAULT,'test') returning a;
a
---
1
(1 row)
INSERT 0 1
Note that there are other ways of doing it, but I really like the
returning clause.
В списке pgsql-sql по дате отправления: