[
https://issues.apache.org/jira/browse/DERBY-4146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12696118#action_12696118
]
Rick Hillegas commented on DERBY-4146:
--------------------------------------
Thanks for finding this bug, Knut. As a workaround, you can explicitly add the
column names to the insert statement. The following works:
insert into t( c1, c2 ) values (default, default);
I think that I agree with you and we should allow tables with this shape.
However, I'm a little unclear about how to interpret the SQL Standard, part 2,
section 4.14.8, which says that generation expressions may not reference other
generated columns. For the purposes of this prohibition, I think that the
standard does not mean to include identity columns as a kind of generated
column. But if someone else has an opinion, please share it.
> Cannot insert row when a generated column references an identity column
> -----------------------------------------------------------------------
>
> Key: DERBY-4146
> URL: https://issues.apache.org/jira/browse/DERBY-4146
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.5.1.0
> Reporter: Knut Anders Hatlen
>
> ij> create table t (c1 int generated always as identity, c2 generated always
> as (c1));
> 0 rows inserted/updated/deleted
> ij> insert into t values (default, default);
> ERROR 23502: Column 'C2' cannot accept a NULL value.
> Preferably, this should work. Alternatively, if it is not supposed to work,
> it should fail when the table is created and the error message should state
> that a generated column is not allowed to reference an identity column.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.