Re: Retrieving Serial Values from ODBC and SPL
Posted in 1999
Trebor You can use DBINFO() to return the last serial value. HTH Sujit "Trebor C. Fenstermaker" <tcfenstermaker@acm.org> on 08/30/99 12:00:45 PM Please respond to "Trebor C. Fenstermaker" <tcfenstermaker@acm.org> To: informix-list@iiug.org cc: (bcc: Sujit Pal) Subject: Retrieving Serial Values from ODBC and SPL Hello, I use the serial datatype extensively to generate unique keys. When building master/detail records, I need--in a programmatic fashion--the generated serial ID from the master insert to key the details. All of this is of course wrapped in a transaction. How? This is easy in Informix 4GL and ESQL/C, both products I've used in past lives. But these days, I'm working with ODBC and JDBC. In JDBC, I can retrieve the returned serial number by casting the prepared statement to a special "IfxStatement," and calling its getSerial() method. This is great for a prepared statement. What about a stored procedure? How do I return a serial value from a stored procedure? Is there a nice clean way by, say, returning the value in sqlerrd[2]? Is this array accessible, in some form, from within the SPL? Similarly, how do I retrieve this value from an ODBC call? No, I'm not using ODBC *with* JDBC, so the two aren't related, but the problem is the same. Am I missing something? Is this not the best way to generate a unique key? Why is it so hard to get its value back while I'm still in a transaction, so I can build the detail records? Trebor Fenstermaker BTG, Inc. Fairfax VA USA