Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

iAnywhere shall support JDBC 3.0's Statement.getGeneratedKeys() method

1 view
Skip to first unread message

Markus KARG

unread,
May 15, 2009, 10:38:43 AM5/15/09
to
SQL Anyhwere 11 can autogenerate id keys (using DEFAULT AUTOINCREMENT or
DEFAULT GLOBAL AUTOINCREMENT) and return them to the caller using SELECT
@@identity.

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.


Karim Khamis [Sybase iAnywhere]

unread,
May 21, 2009, 1:01:27 PM5/21/09
to
Markus,

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

Markus KARG

unread,
May 26, 2009, 6:01:23 AM5/26/09
to
I see. Thank you for this explanation of the problem. So it is a bigger
change than I expected.

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...

Karim Khamis [Sybase iAnywhere]

unread,
May 26, 2009, 9:45:21 AM5/26/09
to
Thanks Markus,

We'll keep your suggestion in mind for a future version of SQL Anywhere.

Karim

Markus KARG

unread,
May 26, 2009, 10:30:03 AM5/26/09
to
Great! :-)

"Karim Khamis [Sybase iAnywhere]" <kkh...@sybase.com> schrieb im

Newsbeitrag news:4a1bf271$1@forums-1-dub...

0 new messages