SERIAL and SERIAL8 data types
HCL OneDB™ JDBC Driver provides support for the HCL OneDB SERIAL and SERIAL8 data types through the methods getSerial() and getSerial8(), which are part of the implementation of the java.sql.Statement interface.
import com.informix.jdbc.*;
0
if
any of the following conditions are true:- The last statement was not an INSERT statement.
- The table being inserted into does not contain a SERIAL or SERIAL8 column.
- The INSERT statement has not executed yet.
If you execute the getSerial() or getSerial8() method
after a CREATE TABLE statement, the method returns 1
by
default (assuming the new table includes a SERIAL or SERIAL8 column).
If the table does not contain a SERIAL or SERIAL8 column, the method
returns 0
. If you assign a new serial starting number,
the method returns that number.
cmd = "insert into serialTable(i) values (100)"; stmt.executeUpdate(cmd); System.out.println(cmd+"...okay"); int serialValue = ((IfmxStatement)stmt).getSerial(); System.out.println("serial value: " + serialValue);
If you want to insert consecutive serial values into a column of
data type SERIAL or SERIAL8, specify a value of 0
for
the SERIAL or SERIAL8 column in the INSERT statement. When the column
is set to 0
, the database server assigns the next-highest
value.
For more detailed information about the HCL OneDB SERIAL and SERIAL8 data types, see the HCL OneDB Guide to SQL: Reference and the HCL OneDB Guide to SQL: Syntax.