Skip site navigation (1) Skip section navigation (2)

Re: Retrieving oid's

From: "Alex Rhomberg" <ar(at)inout(dot)ch>
To: <pgsql-odbc(at)postgresql(dot)org>
Subject: Re: Retrieving oid's
Date: 2001-08-08 21:55:25
Message-ID: GLELJGFLCHABCCPIENAMCEPDCBAA.ar@inout.ch (view raw or flat)
Thread:
Lists: pgsql-odbc
> Is there anyway to get the oid of the just previously inserted record?
>
> Say I do INSERT INTO FOO VALUES ('9');
>
> Can I ask the odbc somehow what the oid was?

If you need this to prevent the record being read-only in access (or
#deleted or something), the trick is to insert a timestamp field as a unique
key in all tables.
On every form that could create a new record, you add a hidden field for the
timestamp and give it a default value of 'localtime' (or whatever the
current time is in VB). This way, Access knows the value of the primary key
from the start and is able to retrieve the record immediately after
insertion.

- Alex

PS: While this is the method that I have implemented after reading it on the
net, an IMHO more elegant value than localtime for the primary key would be
SELECT nextval('some_sequence');
More compact and legible and GUARANTEED to be unique.
Of course the timestamp has an added benefit: It shows the time when a
record was entered...


pgsql-odbc by date

Next:From: Vince VielhaberDate: 2001-08-08 22:34:22
Subject: Re: To be 7.1.3 or not to be 7.1.3?
Previous:From: Alex RhombergDate: 2001-08-08 21:41:14
Subject: Changing ODBC users with Access doesn't work correctly for me

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group