Re: jdbc help needed!
Posted in 1997
Peter Wiley (peter@prospect.anprod.csiro.au) wrote:
: In article <869750631.15772@dejanews.com> r53837@email.sps.mot.com writes:
: >I'm using JDBC drivers to access an informix online 5 database. I've
: >got drivers both from openlink and sco, and with neither can I solve my
: >two problems.
: >
: >The first problem I have is that I have no way of figuring out what value
: >was inserted in a serial column. In embedded SQL, there is the SQLCA
: >structure, which holds the value inserted into a serial column in the last
: >insert; however jdbc doesn't allow access to this structure (does it?).
: >Is there any other way I can do this? I need to know what value was
: >inserted into the serial column in an insert command, so that I can link
: >that tupple somewhere else. The only way I though of involves creating a
: >table, inserting the serial value with a unique value into that secondary
: >table, then looking up the serial value via the unique value, and deleting
: >the entry. This is a three-access procedure just to get a serial value,
: >before I even use it anywhere!!! There's got to be a better way (I
: >certainly hope so!).
: Try using a stored proc to do the insert. THe spl can then get the new
: serial value and return it to you. Since I haven't got the jdbc drivers to
: work for Openlink/Informix combo yet, I can't test this, but it should
: work fine.
Good idea, but unfortunately he is using Online 5.x, in which there is no
way to access the SQLCA structure in a stored procedure. This is a common
problem for ODBC access too. Online 7.x fixed the problem with the new
dbinfo() stored procedure.
In my experience, there is no clean workaround to the problem, although if I
were writing a JDBC driver for Informix I'd be tempted to capture the new
serial value and return it as a ResultSet. Then the information would be
available without breaking the JDBC spec, although it would certainly fall
into the category of database-specific behavior.
--
Jeff Sturm
ZenaComp Incorporated
jsturm@zenacomp.com