LucidDbUpdate

From Eigenpedia

Jump to: navigation, search

NOTE: This feature is currently only available in the 0.8.1 prerelease.

Syntax

UPDATE qualified-table-name [ [ AS ] alias ]
SET { unqualified-column-name = value-expression }, ...
[ WHERE predicate-expression ]

See LucidDbValueExpression for specification of value-expression and predicate-expression.

See LucidDbUniqueConstraints for interaction between updates and uniqueness constraints.

Alternate Method

Versions 0.8.0 and earlier do not support the syntax above. For those versions, use the following equivalent SQL (assuming your table has a primary key):

MERGE INTO qualified-table-name AS tgt
USING qualified-table-name AS src
ON src.primary_key = tgt.primary_key AND predicate-expression
WHEN MATCHED THEN
UPDATE SET { unqualified-column-name = value-expression }, ...

Example

UPDATE warehouse.timesheet_fact
SET hours_worked = hours_worked + 1
WHERE emp_key=6

which is equivalent to

MERGE INTO warehouse.timesheet_fact AS tgt
USING warehouse.timesheet_fact AS src
ON src.timesheet_key = tgt.timesheet_key AND emp_key=6
WHEN MATCHED THEN
UPDATE SET hours_worked = src.hours_worked + 1;
Personal tools