[
https://issues.apache.org/jira/browse/DERBY-3609?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12587233#action_12587233
]
Oleksandr Alesinskyy commented on DERBY-3609:
---------------------------------------------
Regrettably, after INSERT...SELECT returned resultset contains not null as you
stated, but key generated by last single row INSERT..VALUES on the same table.
This behavior is completely misleading. It is bad enough for
IDENTITY_VAL_LOCAL(), but (IMHO) absolutely unacceptable for
getGeneratedKeys().
And here is log from test programm that proves my point:
---------------------------------------------------------------------------
insert values has generated id 1, is null false
insert as select same table has inserted 1 rows
insert as select from same table has generated id 1, is null false
insert as select from another table has inserted 1 rows
insert as select from another has generated id 1, is null false
MUMU contents id 1, is null false
MUMU contents id 2, is null false
MUMU contents id 3, is null false
Done.
------------------------------------------------------------------------------
Progam source is attached
> Wrong functionality of auto-generated keys support
> --------------------------------------------------
>
> Key: DERBY-3609
> URL: https://issues.apache.org/jira/browse/DERBY-3609
> Project: Derby
> Issue Type: Bug
> Components: JDBC
> Affects Versions: 10.3.2.1
> Environment: N/A
> Reporter: Oleksandr Alesinskyy
>
> Currently support for autogeneration key retrieval in JDBC driver
> (java.sql.Statement) relies on IDENTITY_VAL_LOCAL function, which means that
> for multi-row INSERT... VALUES statements as well as for INSERT...AS SELECT
> statement wrong result are returned (key generated of last executed
> single-row INSERT...VALUES statement or NULL otherwise). While this
> functionality is documented in the Reference description of
> IDENTITY_VAL_LOCAL it is not so clearly documented in "autogenerated keys"
> subchapter of JDBC 3.0 Features (the only vague hint is "Calling
> ResultSet.getMetaData on the ResultSet object returned by getGeneratedKeys
> produces a ResultSetMetaData object that is similar to that returned by
> IDENTITY_VAL_LOCAL.").
> Moreover, as far as I understant it diverge from JDBC specification. IMHO or
> this functionality shal lbe implemented completely, or exception shall be
> thrown if for given statement functionality is not supported (e.g. "Feature
> not supported").
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.