You can try using the CASE
statement
UPDATE [table]
SET [field] =
CASE
WHEN field2 = 'Y'
THEN [value1]
WHEN field2 = 'N'
THEN [value2]
ELSE
END;
Frage
I am wondering if there is a conditional selection between values in PL/SQL as there is the following in C-based languages: [condition] ? [value1] : [value2]
.
I would like to use it in an update statement as such:
UPDATE [table] SET [field] = [condition] ? [value1] : [value2] WHERE [where clause];
I've already though of DECODE
, but I would like to use it directly and not store its result in a variable and then use it in the update statement.
Lösung
You can try using the CASE
statement
UPDATE [table]
SET [field] =
CASE
WHEN field2 = 'Y'
THEN [value1]
WHEN field2 = 'N'
THEN [value2]
ELSE
END;