Skip to content
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

Closed
firebird-automations opened this issue Jan 11, 2017 · 12 comments

Comments

@firebird-automations
Copy link
Collaborator

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

@firebird-automations
Copy link
Collaborator Author

Modified by: @mrotteveel

Link: This issue replaces CORE1311 [ CORE1311 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @mrotteveel

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

@firebird-automations
Copy link
Collaborator Author

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.

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @mrotteveel

Link: This issue is duplicated by CORE665 [ CORE665 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @mrotteveel

It seems like CORE665 is a duplicate of this one, I suggest CORE665 gets closed in favor of this one.

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

summary: Support DEFAULT context value in insert, update, merge, etc => Support DEFAULT context value in INSERT, UPDATE, MERGE and UPDATE OR INSERT statements

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 4.0 Alpha 1 [ 10731 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: hamacker (hamacker)

Any possibility to introduces this context value to current version of Firebird (v3)?
It´s be wellcome with new identity fields.

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

> Any possibility to introduces this context value to current version of Firebird (v3)?
> It´s be wellcome with new identity fields.

Very low possibility.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

QA Status: No test => Done successfully

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants