Re: [HACKERS] getting new serial value of serial insert - Mailing list pgsql-hackers

From Aaron J. Seigo
Subject Re: [HACKERS] getting new serial value of serial insert
Date
Msg-id 99110313340704.00702@stilborne
Whole thread Raw
In response to [HACKERS] getting new serial value of serial insert  (Ed Loehr <ELOEHR@austin.rr.com>)
List 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


pgsql-hackers by date:

Previous
From: Ed Loehr
Date:
Subject: [HACKERS] getting new serial value of serial insert
Next
From: Ed Loehr
Date:
Subject: Re: [HACKERS] getting new serial value of serial insert