Re: [HACKERS] getting new serial value of serial insert

From: "Aaron J(dot) Seigo" <aaron(at)gtv(dot)ca>
To: Ed Loehr <ELOEHR(at)austin(dot)rr(dot)com>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] getting new serial value of serial insert
Date: 1999-11-03 20:16:13
Message-ID: 99110313340704.00702@stilborne
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi...

> create table mytable (id serial, name varchar);
>
> -- this returns # of rows inserted, as usual...
> insert into mytable (name) values ('John');
>
> -- this returns serial 'id' of inserted record...
> insert into mytable (id,name) values (0,'Mary');

hm.. this is very elegant syntactically..

however, it would be nice to be able to have returned any number of fields of
any types... (for example, i have a trigger that changes a field in a record
whenever it gets updated/inserted.. it would be nice to get this returned as
well...)

also, if possible, it would be nice to extend this to UPDATE...

can you think of a way to use this syntax aproach that would meet the needs
above?

> select id from mytable where oid = $sth->{pg_oid_status}
>
> Seems a waste to have to do this, but I'm not aware of another way.

*nods* seems quite a few people are running into this.

--
Aaron J. Seigo
Sys Admin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ed Loehr 1999-11-03 20:19:28 Re: [HACKERS] getting new serial value of serial insert
Previous Message Aaron J. Seigo 1999-11-03 19:21:00 Re: [HACKERS] Get OID of just inserted record