SQL> UPDATE tableA A SET A.val= ( SELECT DECODE(A.type,1,B.val1,2,B.val2) FROM tableB B WHERE B.cat=
A.cat);
6 rows updated.
SQL> select * from tableA;
C TYPE VAL
- ---------- ----------
a 1 1000
a 2 1234
b 1
b 2
c 1 2020
c 2 2101
6 rows selected.
I changed it to
UPDATE tableA A
SET A.val= (
SELECT DECODE(A.type,1,B.val1,2,B.val2)
FROM tableB B
WHERE B.cat=A.cat
)
WHERE A.cat in (SELECT cat FROM tableB)
then
4 rows updated.
SQL> select * from tableA;
C TYPE VAL
- ---------- ----------
a 1 1000
a 2 1234
b 1 511
b 2 201
c 1 2020
c 2 2101
6 rows selected.
Done. Thanks a lot!
A.cat);
6 rows updated.
SQL> select * from tableA;
C TYPE VAL
- ---------- ----------
a 1 1000
a 2 1234
b 1
b 2
c 1 2020
c 2 2101
6 rows selected.
I changed it to
UPDATE tableA A
SET A.val= (
SELECT DECODE(A.type,1,B.val1,2,B.val2)
FROM tableB B
WHERE B.cat=A.cat
)
WHERE A.cat in (SELECT cat FROM tableB)
then
4 rows updated.
SQL> select * from tableA;
C TYPE VAL
- ---------- ----------
a 1 1000
a 2 1234
b 1 511
b 2 201
c 1 2020
c 2 2101
6 rows selected.
Done. Thanks a lot!