> The problem is that this does not actually give me the number that
> was just created. As there is no guarantee that the other fields in
> the table are unique (hence the serial field in the first place) I cannot
> simply do a select to retrieve it.
When doing development with OO development tools and using wrappers
to handle the oo <-> rdbms wall one has to look at the unique identifier
Here again, two possible ways are possible:
- let the database handle the serial number stuff
- let the software handle the serial number stuff
In general it is said not to use special features of databases if they
are ot portable - the software way is very often very portable.
For our wrapper in Smalltalk/X we decided NOT to use the Postgre support
for serial numbers, but do it on our own.
Several papers are out in the internet, which tells one how to create
such number, which fits several points:
- unique number in multiconnection environment
- minimize the amount of communication between client and database
while handling this stuff.
The principle for the high-low algorithm is:
- the client gets a session id on startup - asking the database for
the next valid session number.
- the unique keys are created on the client side without any further
interaction between client and database.
- the unique key is based on a session id and a id within a session.
- to get it into one column you may put these values together and perhaps
convert them to a string.
- if the client exits it writes its session value and the actual
id within the session back to the database - for further use by the
If anyone wishes further information about this you may send me an
In response to
pgsql-interfaces by date
|Next:||From: Gene Sokolov||Date: 1999-12-09 10:06:13|
|Subject: ODBC and DECIMAL column width|
|Previous:||From: Peter Mount||Date: 1999-12-09 07:39:27|
|Subject: RE: [INTERFACES] Transaction support in 6.5.3/JDBC |