Re: need jdbc help!!
Posted in 1997
In article <33D776A3.FFCF14DE@informix.com>,
>adil@msil.sps.mot.com wrote:
> > 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
"Mark D. Stock" <mdstock@informix.com> wrote:
>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.
I'd suggest you do the SELECT against a smaller table, and so save the
engine some work:
SELECT dbinfo("sqlca.sqlerrd1")
FROM systables
WHERE tabname = "systables"
Wrap this in a stored procedure called "LastSerialNumber" or something
and make your programs nicely isolated from this weirdness.
> > 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.
The following pseduocode illustrates how to identify whether or not a
given column is a serial datatype:
SELECT coltype FROM syscolumns, systables
WHERE tabname = "sometable"
AND colname = "somecolumn"
AND syscolumns.tabid = systables.tabid
IF coltype = 6 OR coltype = 256 + 6 THEN
DISPLAY "sometable.somecolumn is a SERIAL column"
END IF
For more information check out the Informix FAQ, Appendices E and F, as
advertised in my signature lines.
Cheers,
Kerry "Happy to have a working computer again" S
------------------------------------,------------------------------------------
Kerry Sainsbury, kerry@kcbbs.gen.nz | THE INFORMIX FAQ v2.10 May 1997
Quanta Systems, Auckland | http://www.iiug.org/techinfo/faq/
New Zealand. Work: +64 9 377-4473 | ftp://ftp.iiug.org/pub/informix/faq
Home: +64 9 279-3571 | ftp://kcbbs.gen.nz:/pub/informix/