Thread: using Oids to retrieve a row
anyone know if it is possible to INSERT a row , "save" the oid for this row and subsequently select it based only on the oid ? -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ David O'Farrell AerSoft Limited mailto:dave.ofarrell@aersoft.ie 2 Northumberland Avenue, Dun Laoghaire,Co. Dublin Direct Phone 353-1-2145950 Phone: 01-2301166 Fax: 01-2301167 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
are you doing this in psql? Or perl, php, or some other? perl and php both have methods for getting the oid of the last inserted row (use "$oid = $sth->{'pg_oid_status'};" in perl and "$oid = pg_GetLastOid($result_id);" in php ) Look at the php documentation, or do 'perldoc DBD::Pg' to see more details. I think the postgres documentation for PL/Tcl also has a quick and simple way of doing what you want, but I can't seem to find it now so I'm not sure about that. Karl
At 18:32 +0200 on 26/03/1999, Karl DeBisschop wrote: > are you doing this in psql? > > Or perl, php, or some other? > > perl and php both have methods for getting the oid of the last > inserted row (use "$oid = $sth->{'pg_oid_status'};" > in perl and "$oid = pg_GetLastOid($result_id);" in php ) > Look at the php documentation, or do 'perldoc DBD::Pg' > to see more details. A word of warning, though: retrieving a row by its oid doesn't make retrieval faster. You have to create an index on the oid column, otherwise it's plain sequential search. Personally, I prefer defining an indexed serial field and using currval. Herouth -- Herouth Maoz, Internet developer. Open University of Israel - Telem project http://telem.openu.ac.il/~herutma