Issue Details (XML | Word | Printable)

Key: CORE-4580
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Jonas Jasas
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Accessible field values in UPDATE OR INSERT INTO

Created: 16/Oct/14 10:12 AM   Updated: 17/Oct/14 06:09 AM
Component/s: Engine
Affects Version/s: 2.5.3
Fix Version/s: None


 Description  « Hide
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 (
    table1.id,
    table1.code,
    table1.name
) VALUES (
    COALESCE(table1.id, NEXT VALUE FOR ID),
    '007',
    'James'
) MATCHING (
    table1.code
);


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Sean Leyne added a comment - 16/Oct/14 02:58 PM
What is the primary key of Table1?

Jonas Jasas added a comment - 17/Oct/14 06:09 AM
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 (
    babies.id,
    babies.age,
    babies.name
) VALUES (
    COALESCE(babies.id, NEXT VALUE FOR ID),
    COALESCE(babies.age + 1, 1),
    'James'
) MATCHING (
    babies.name
);

If babe found, increasing age.