Re: best way to keep track of unique id numbers on inserts
Posted in 2000
Topics: SQL Development & Query Writing, Java & JDBC Development
Hmm, thanks that helps. I'm working in Java and should be able to run that
SQL statement and pull out the value with a ResultSet. But, my question
still remains: with simultaneous usage, can I rely on it pulling out this
sqlca.sqlerrd1 value before the next person gets inserted thereby changing
the value? Is this variable seperate for each DB connection, or is it a
global value that may get changed from another statement executing on a
different connection?
Thanks for your help,
Kevin
-----Original Message-----
From: William Harris <william@carsinfo.com>
To: informix-list@iiug.org <informix-list@iiug.org>
Date: Wednesday, May 24, 2000 7:29 AM
Subject: Re: best way to keep track of unique id numbers on inserts
>In article <8geqp8$f2o$1@news.xmission.com>, kmacclay@vantage.com says...
>>But
>>then we had to do a select statement immediately afterwards in order to
find
>>out what number the database chose for the id. The problem here is we
have
>>many simultaneous users and there is a possibility that before the select
>>statement gets called, someone else inserts a record, and so the wrong id
>>number is pulled out.
>
>You didn't mention the environment you're working under; Informix can
>give you the last serial number inserted via SELECT
DBINFO('sqlca.sqlerrd1').>If you're in an environment where you have little control over the actual
SQL
>that gets sent to the engine, this may be a bit difficult to use. The
older
>Visual Basic database controls were downright nasty about this, but the
newer
>controls should allow you enough control over the database connection to
allow
>you to use DBINFO select.
>--
>William Harris william@carsinfo.com
>
In article <8ggmls$fvg$1@news.xmission.com>, chalupa@vantage.com says... >Hmm, thanks that helps. I'm working in Java and should be able to run that >SQL statement and pull out the value with a ResultSet. But, my question >still remains: with simultaneous usage, can I rely on it pulling out this >sqlca.sqlerrd1 value before the next person gets inserted thereby changing >the value? It's unique to each connection; it can be relied upon. All you really have to worry about is making sure no other database calls in that particular connection occur between the insert and the dbinfo call, which as I said can be a problem with some database beans or components. I don't know how the popular environments' beans behave in this respect. -- William Harris william@carsinfo.com