OID use

Started by Jeff Davisover 25 years ago2 messagesgeneral
Jump to latest
#1Jeff Davis
jdavis@genesiswd.com

Here is essentially what I am trying to do:

I want to have a 'serial' type column, so that it provides a unique
identifier for records. However, when I do the insert, I need the know
what value was assigned to that so I can use it in another table for
reference, by doing another insert.

I looked at the C API and found a function 'PQoidValue' which returns an
Oid. I tried to find a place to use the Oid type, but could not. Is
there a more efficient way of getting record information than executing
a 'select * where ... oid=...'? And what restrictions should I be aware
of when working with Oids?

Regards,
Jeff Davis

#2Peter T Mount
peter@retep.org.uk
In reply to: Jeff Davis (#1)
Re: OID use

On Thu, 5 Oct 2000, Jeff Davis wrote:

Here is essentially what I am trying to do:

I want to have a 'serial' type column, so that it provides a unique
identifier for records. However, when I do the insert, I need the know
what value was assigned to that so I can use it in another table for
reference, by doing another insert.

When you have used your SERIAL, the currval() function holds the last
value inserted. It's the only way to guarantee getting the correct value,
especially when there's multiple sessions going on.

Peter

--
Peter T Mount peter@retep.org.uk http://www.retep.org.uk
PostgreSQL JDBC Driver http://www.retep.org.uk/postgres/
Java PDF Generator http://www.retep.org.uk/pdf/