I read in the release notes that there is a currval function to retrieve the value generated by a auto_increment column.
I tried following sql, but the currval select returned an error.
How should this be done?
create table tst (id integer not null auto_increment, val integer default null, primary key (id))
insert into tst (val) values (100)
>How should this be done?
You doen't use SEQUENCE so that you needn't use currval.
You should use Statement.RETURN_GENERATED_KEYS. For instance,
stmt.executeUpdate("insert into tst (val) values (100);",Statement.RETURN_GENERATED_KEYS);
System.out.println("The id for inserted row is "+rs.getObject(1));
But why does the currval not work?
I could not use Statement.RETURN_GENERATED_KEYS when I want to script it all
is correct according to API document.
Please download the latest package after about 3 hours.