I'm trying to write a single query to update a value in one field based on a value in another field. The updated value is pulled from one of two tables, which is determined by the value in the second field.
I've tried this:
UPDATE
T1 tbl
SET
tbl.F1 =
(
IF
(
tbl.F2 = 1,
(SELECT T2.F2 FROM T2 WHERE T2.F1 = tbl.F1),
IF
(tbl.F2 = 2,
(SELECT T3.F2 FROM T3 WHERE T3.F1 = tbl.F1),
tbl.F1
)
)
)
Pervasive apparetnly doesn't like this usage io IF and SELECT. Does anyone have any ideas?
I've tried this:
UPDATE
T1 tbl
SET
tbl.F1 =
(
IF
(
tbl.F2 = 1,
(SELECT T2.F2 FROM T2 WHERE T2.F1 = tbl.F1),
IF
(tbl.F2 = 2,
(SELECT T3.F2 FROM T3 WHERE T3.F1 = tbl.F1),
tbl.F1
)
)
)
Pervasive apparetnly doesn't like this usage io IF and SELECT. Does anyone have any ideas?