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

DEFAULT Keyword [CORE665] #1031

Closed
firebird-automations opened this issue Feb 28, 2005 · 10 comments
Closed

DEFAULT Keyword [CORE665] #1031

firebird-automations opened this issue Feb 28, 2005 · 10 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Pierre Yager (pierrey)

Duplicates CORE5449

Votes: 4

SFID: 1153278#⁠
Submitted By: pierrey

I would like to know I you can consider adding
a "DEFAULT" keyword to force the engine to set the
default value for a field if this field is present in a query
(insert or update) but user don't want to give it a value :

CREATE TABLE MY_TABLE (
TABLE_KEY INTEGER NOT NULL,
TABLE_VALUE INTEGER NOT NULL DEFAULT 0,
CONSTRAINT MY_TABLE_PK PRIMARY KEY
(TABLE_KEY));

INSERT INTO MY_TABLE (TABLE_KEY,
TABLE_VALUE) VALUES
(GEN_ID(MY_GEN_KEY), DEFAULT);

or

UPDATE MY_TABLE SET
TABLE_VALUE=DEFAULT
WHERE TABLE_KEY=:THE_ID;

Vlad Horsun also said this keyword is in SQL 2002 :

"We talk about INSERT\UPDATE syntax with explicit
defaults.

This is feauture F221 according SQL 2002 (which i has)

SQL 2002 say:

6.5 <contextually typed value specification>

Function
Specify a value whose data type is to be inferred from
its context.

Format
<contextually typed value specification> ::= <implicitly
typed value specification>
| <default specification>
...
<default specification> ::=
DEFAULT

Both INSERT and UPDATE can specify <contextually
typed value specification>"

@firebird-automations
Copy link
Collaborator Author

Modified by: Alice F. Bird (firebirds)

description: SFID: 1153278#⁠
Submitted By: pierrey

I would like to know I you can consider adding
a "DEFAULT" keyword to force the engine to set the
default value for a field if this field is present in a query
(insert or update) but user don't want to give it a value :

CREATE TABLE MY_TABLE (
TABLE_KEY INTEGER NOT NULL,
TABLE_VALUE INTEGER NOT NULL DEFAULT 0,
CONSTRAINT MY_TABLE_PK PRIMARY KEY
(TABLE_KEY));

INSERT INTO MY_TABLE (TABLE_KEY,
TABLE_VALUE) VALUES
(GEN_ID(MY_GEN_KEY), DEFAULT);

or

UPDATE MY_TABLE SET
TABLE_VALUE=DEFAULT
WHERE TABLE_KEY=:THE_ID;

Vlad Horsun also said this keyword is in SQL 2002 :

"We talk about INSERT\UPDATE syntax with explicit
defaults.

This is feauture F221 according SQL 2002 (which i has)

SQL 2002 say:

6.5 <contextually typed value specification>

Function
Specify a value whose data type is to be inferred from
its context.

Format
<contextually typed value specification> ::= <implicitly
typed value specification>
| <default specification>
...
<default specification> ::=
DEFAULT

Both INSERT and UPDATE can specify <contextually
typed value specification>"

=>

SFID: 1153278#⁠
Submitted By: pierrey

I would like to know I you can consider adding
a "DEFAULT" keyword to force the engine to set the
default value for a field if this field is present in a query
(insert or update) but user don't want to give it a value :

CREATE TABLE MY_TABLE (
TABLE_KEY INTEGER NOT NULL,
TABLE_VALUE INTEGER NOT NULL DEFAULT 0,
CONSTRAINT MY_TABLE_PK PRIMARY KEY
(TABLE_KEY));

INSERT INTO MY_TABLE (TABLE_KEY,
TABLE_VALUE) VALUES
(GEN_ID(MY_GEN_KEY), DEFAULT);

or

UPDATE MY_TABLE SET
TABLE_VALUE=DEFAULT
WHERE TABLE_KEY=:THE_ID;

Vlad Horsun also said this keyword is in SQL 2002 :

"We talk about INSERT\UPDATE syntax with explicit
defaults.

This is feauture F221 according SQL 2002 (which i has)

SQL 2002 say:

6.5 <contextually typed value specification>

Function
Specify a value whose data type is to be inferred from
its context.

Format
<contextually typed value specification> ::= <implicitly
typed value specification>
| <default specification>
...
<default specification> ::=
DEFAULT

Both INSERT and UPDATE can specify <contextually
typed value specification>"

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

priority: Major [ 3 ] => Minor [ 4 ]

Fix Version: 3.0 [ 10048 ]

SF_ID: 1153278 =>

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Workflow: jira [ 10689 ] => Firebird [ 15071 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Fix Version: 3.0 Alpha 1 [ 10331 ]

Fix Version: 3.0.0 [ 10048 ] =>

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Fix Version: 3.0 Beta 1 [ 10332 ]

Fix Version: 3.0 Alpha 1 [ 10331 ] =>

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Fix Version: 3.0 Beta 1 [ 10332 ] =>

@firebird-automations
Copy link
Collaborator Author

Commented by: Lukas Eder (lukas.eder)

It's been a while since this issue was created ;-)

Interestingly, Firebird supports the less useful DEFAULT VALUES clause for INSERT statements as can be seen here:
http://www.firebirdsql.org/refdocs/langrefupd21-insert.html

But the DEFAULT keyword for INSERT or UPDATE is really more useful.

@firebird-automations
Copy link
Collaborator Author

Commented by: @aafemt

1) Should word DEFAULT in UPDATE clause set the field to default value or leave old value intact?
2) How should be possible to use it with parameterized queries?

@firebird-automations
Copy link
Collaborator Author

Modified by: @mrotteveel

Link: This issue duplicates CORE5449 [ CORE5449 ]

@hvlad
Copy link
Member

hvlad commented May 5, 2021

Replaced by #5720 [CORE5449 ]

@hvlad hvlad closed this as completed May 5, 2021
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