JDBC API 3 knows the method Statement.getGeneratedKeys() to retrieve such
autogenerated id keys. Currently the iAnywhere JDBC driver does not
implement this method, resulting in a SQLException. A client side program
always must do an explicit SELECT @@identity to get the generated value.
To make client side programming easier, it would be nice if the JDBC driver
would implement the getGeneratedKeys method.
Consider the following...
Connection c = ...
Statement s = c.createStatement();
s.execute( "create table t(c1 int, c2 int default autoincrement, c3 int
default autoincrement );
s.executeUpdate( "insert into t(c1) select table_id from sys.systable" );
ResultSet r = s.getGeneratedKeys();
According to the JDBC specification, the ResultSet r above should now
contain ALL of the automatically generated values resulting from the
execution of Statement s. That means that r should contain all auto
incremented values inserted into columns c2 and c3. Calling select
@@identity only returns the last auto generated value. There is no way
in SQL Anywhere to obtain the full list of auto generated values
resulting from the execution of a statement.
Karim
Maybe it would be possible to temporarily store each created PK in a local
temporary table? Should not consume too much runtime and is potentially not
too hard to implement?
Regards
Markus
"Karim Khamis [Sybase iAnywhere]" <kkh...@sybase.com> schrieb im
Newsbeitrag news:4a1588e7@forums-1-dub...
We'll keep your suggestion in mind for a future version of SQL Anywhere.
Karim
"Karim Khamis [Sybase iAnywhere]" <kkh...@sybase.com> schrieb im
Newsbeitrag news:4a1bf271$1@forums-1-dub...