Re: need jdbc help!!
Posted in 1997
adil@msil.sps.mot.com wrote:
>
> 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!).
>
> The second problem I have is even identifying that a column is a
> serial
> column. The ResultSetMetaData class has a "isAutoIndent" method, but
> it
> is not implemented. I figure it out by looking in the system
catalog,
> but for that I need the "getTableName" method, and that doesn't work
> either. Is there any way I can figure out that a certain column from
> a
> query I make is a serial column? This is important, because it is
> impossible to update serial columns.
>
> Thanks for any help anyone can give,
The first one I can help with, the second not.
If you issue:
INSERT INTO customer (customer_num, fname, lname)
VALUES(0, "Mark", Stock")
where customer_num is of type SERIAL, then:
SELECT DISTINCT dbinfo("sqlca.sqlerrd1")
FROM customer
will return the last SERIAL value. The DISTINCT (UNIQUE) is used to
return a single value.
Hope that helps,
--
Mark.
+----------------------------------------------------------+-----------+
|Mark D. Stock - Informix SA http://www.informix.com |//////// /|
|mailto:mdstock@informix.com FAQ http://www.iiug.org |///// / //|
| +-----------------------------------+//// / ///|
| Tel: +27 11 807 0313 |If it's slow, the users complain. |/// / ////|
| Fax: +27 11 807 2594 |If it's fast, the users keep quiet.|// / /////|
|Cell: +27 83 250 2325 |Therefore, "No news: travels fast"!|/ ////////|
+----------------------+-----------------------------------+-----------+