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

Accessible field values in UPDATE OR INSERT INTO [CORE4580] #4896

Open
firebird-automations opened this issue Oct 16, 2014 · 3 comments
Open

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Jonas Jasas (jon)

Make it possible to access field values in VALUES statement if it is UPDATE, if INSERT then values can be NULL. That would make this possible:
UPDATE OR INSERT INTO table1 (
http://table1.id,
table1.code,
http://table1.name
) VALUES (
COALESCE(http://table1.id, NEXT VALUE FOR ID),
'007',
'James'
) MATCHING (
table1.code
);

@firebird-automations
Copy link
Collaborator Author

Modified by: Jonas Jasas (jon)

description: Make it possible to access field values in VALUES statement if it is UPDATE, if INSERT then values can be NULL. That would make this possible:
UPDATE OR INSERT INTO table1 (
http://table1.id,
table1.code,
http://table1.name
) VALUES (
COALESCE(http://table1.id, gen_id(id)),
'007',
'James'
) MATCHING (
table1.code
);

=>

Make it possible to access field values in VALUES statement if it is UPDATE, if INSERT then values can be NULL. That would make this possible:
UPDATE OR INSERT INTO table1 (
http://table1.id,
table1.code,
http://table1.name
) VALUES (
COALESCE(http://table1.id, NEXT VALUE FOR ID),
'007',
'James'
) MATCHING (
table1.code
);

@firebird-automations
Copy link
Collaborator Author

Commented by: Sean Leyne (seanleyne)

What is the primary key of Table1?

@firebird-automations
Copy link
Collaborator Author

Commented by: Jonas Jasas (jon)

Primary key is not relevant to this feature, but lets say PK is on ID field. This is another use example:
UPDATE OR INSERT INTO babies (
http://babies.id,
babies.age,
http://babies.name
) VALUES (
COALESCE(http://babies.id, NEXT VALUE FOR ID),
COALESCE(babies.age + 1, 1),
'James'
) MATCHING (
http://babies.name
);

If babe found, increasing age.

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

1 participant