Re: A way to get autogenerated keys
Posted in 2006
Preparing or opening a JDBC callable statement for the "select dbinfo" is probably clearing the "sqlerrd" values before the row is fetched. A solution would be to create a stored procedure to insert the row, select the last serial value and then return it. Alternatively, if it is indexed, you could perhaps use this instead: select max(serial-column-name) from table-name -- Regards, Doug Lawry www.douglawry.webhop.org "Salch, Chris" <ChrisSalch@letu.edu> wrote in message news:mailman.535.1165987911.29126.informix-list@iiug.org... I need a way to find an auto generated key after an insert statement. I'm working with informix 9.40.HC5 on an HPUX box and have tried the following query, which works quite well on an informix 10 test machine: select dbinfo('sqlca.sqlerrd1') from systables where tabname='systables' Unfortunately, it always returns 0. I've tried this with dbinfo('serial8'), tabid=1 and several combinations of these. Nothing has worked for me yet. Any suggestions? (If there is a nice way to get the ibm jdbc driver to return it's keys according to the jdbc standard and not some obfuscated method I would gladly settle for that :)