| From: | Dani Oderbolz <oderbolz(at)ecologic(dot)de> | 
|---|---|
| To: | pgsql-novice(at)postgresql(dot)org | 
| Subject: | Re: can you select on an OID? | 
| Date: | 2003-04-23 07:22:37 | 
| Message-ID: | 3EA63F3D.4020804@ecologic.de | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-novice | 
Hi Jay,
>I want to insert a row; one of the items in the row is of
>type SERIAL.  After I insert the row, I want to know what
>value was assigned to the SERIAL item, call it the f_id.
>
Whenever you create a SERIAL column, Postgresql creates an imlicit 
Sequence in the background
(as SERIAL isn´t a real Datatype).
I am not entirely sure about the naming convention of this implicit 
sequequence, I think it is like this:
TABBLENAME_COLUMNNAME_seq
So, you can get what you need using the currval function.
So if your table looks like this:
CREATE TABLE test
( first   SERIAL );
then you can get the value like this:
SELECT currval('test_first_seq');
Regards, Dani
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dave Page | 2003-04-23 10:37:09 | Re: [pgadmin-support] large object oid value not showing up in pgAdmin | 
| Previous Message | Williams, Travis L, NPONS | 2003-04-22 23:46:34 | Re: Select current_timestamp as a different timezone.. |