New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support DEFAULT context value in INSERT, UPDATE, MERGE and UPDATE OR INSERT statements [CORE5449] #5720
Comments
Modified by: @mrotteveel |
Modified by: @mrotteveeldescription: Please add support for the SQL standard DEFAULT context value, which means use the default value of the column assigned (insert, update, merge, etc), or NULL if there is no default. This is defined in (SQL:2011): 6.5 <contextually typed value specification>, with explicit instructions for insert, update, merge, etc. This is already supported by for example PostgreSQL. This feature should allow for example: insert into sometable (id, column1) values (default, 'name') If id is an identity column this will cause the identity value to be generated. Note that this should also be supported when including other generated/computed columns in the insert (or update, merge, etc) statement: insert into sometable (column1, column2, somecomputedcolumn) values ('value', 'othervalue', default) Other examples: update sometable set column1 = 'a', column2 = default (similar for merge) The currently supported "insert into sometable default values" is actually a special case where all columns have default (see 14.11 <insert statement>: "An <insert columns and source> that specifies DEFAULT VALUES is implicitly replaced by an <insert columns and source> that specifies a <contextually typed table value constructor> of the form VALUES (DEFAULT, DEFAULT, ..., DEFAULT) where the number of instances of "DEFAULT" equal to the number of columns of T.") This ticket should replace CORE1311 which requests this behavior when using NULL, which is not correct behavior. => Please add support for the SQL standard DEFAULT context value, which means use the default value of the column assigned (insert, update, merge, etc), or NULL if there is no default. This is defined in (SQL:2011): 6.5 <contextually typed value specification>, with explicit instructions for insert, update, merge, etc. This is already supported by for example PostgreSQL, SQL Server and Oracle. This feature should allow for example: insert into sometable (id, column1) values (default, 'name') If id is an identity column this will cause the identity value to be generated. Note that this should also be supported when including other generated/computed columns in the insert (or update, merge, etc) statement: insert into sometable (column1, column2, somecomputedcolumn) values ('value', 'othervalue', default) Other examples: update sometable set column1 = 'a', column2 = default (similar for merge) The currently supported "insert into sometable default values" is actually a special case where all columns have default (see 14.11 <insert statement>: "An <insert columns and source> that specifies DEFAULT VALUES is implicitly replaced by an <insert columns and source> that specifies a <contextually typed table value constructor> of the form VALUES (DEFAULT, DEFAULT, ..., DEFAULT) where the number of instances of "DEFAULT" equal to the number of columns of T.") This ticket should replace CORE1311 which requests this behavior when using NULL, which is not correct behavior. |
Commented by: @aafemt Also it would be good if this feature was available at API level as a special value of null indicator to work with parameterized queries. |
Modified by: @asfernandesassignee: Adriano dos Santos Fernandes [ asfernandes ] |
Modified by: @mrotteveel |
Commented by: @mrotteveel It seems like CORE665 is a duplicate of this one, I suggest CORE665 gets closed in favor of this one. |
Modified by: @asfernandessummary: Support DEFAULT context value in insert, update, merge, etc => Support DEFAULT context value in INSERT, UPDATE, MERGE and UPDATE OR INSERT statements |
Modified by: @asfernandesstatus: Open [ 1 ] => Resolved [ 5 ] resolution: Fixed [ 1 ] Fix Version: 4.0 Alpha 1 [ 10731 ] |
Commented by: hamacker (hamacker) Any possibility to introduces this context value to current version of Firebird (v3)? |
Commented by: @asfernandes > Any possibility to introduces this context value to current version of Firebird (v3)? Very low possibility. |
Modified by: @pavel-zotovstatus: Resolved [ 5 ] => Resolved [ 5 ] QA Status: No test => Done successfully |
Modified by: @pavel-zotovstatus: Resolved [ 5 ] => Closed [ 6 ] |
Submitted by: @mrotteveel
Replaces CORE1311
Is duplicated by CORE665
Votes: 1
Please add support for the SQL standard DEFAULT context value, which means use the default value of the column assigned (insert, update, merge, etc), or NULL if there is no default. This is defined in (SQL:2011): 6.5 <contextually typed value specification>, with explicit instructions for insert, update, merge, etc. This is already supported by for example PostgreSQL, SQL Server and Oracle.
This feature should allow for example:
insert into sometable (id, column1) values (default, 'name')
If id is an identity column this will cause the identity value to be generated.
Note that this should also be supported when including other generated/computed columns in the insert (or update, merge, etc) statement:
insert into sometable (column1, column2, somecomputedcolumn) values ('value', 'othervalue', default)
Other examples:
update sometable set column1 = 'a', column2 = default
(similar for merge)
The currently supported "insert into sometable default values" is actually a special case where all columns have default (see 14.11 <insert statement>: "An <insert columns and source> that specifies DEFAULT VALUES is implicitly replaced by an <insert columns and source> that specifies a <contextually typed table value constructor> of the form VALUES (DEFAULT, DEFAULT, ..., DEFAULT) where the number of instances of "DEFAULT" equal to the number of columns of T.")
This ticket should replace CORE1311 which requests this behavior when using NULL, which is not correct behavior.
Commits: c363946
The text was updated successfully, but these errors were encountered: