1 2 3 4 5 6 7 8 9 10 11 12 13 | BEGIN FOR l IN ( SELECT table1. no AS no , table2.phone AS phone FROM table2, table1 WHERE table1. NO = table2. NO ) LOOP UPDATE table1 SET table1.phone = l.phone WHERE table1. no = l. no ; END LOOP; COMMIT ; END ; / <br><br>Oracle 강좌탭에서 PL/SQL강좌 참고하세요~ |
1 2 3 4 5 6 7 8 9 10 11 12 13 | BEGIN FOR l IN ( SELECT table1. no AS no , table2.phone AS phone FROM table2, table1 WHERE table1. NO = table2. NO ) LOOP UPDATE table1 SET table1.phone = l.phone WHERE table1. no = l. no ; END LOOP; COMMIT ; END ; / <br><br>Oracle 강좌탭에서 PL/SQL강좌 참고하세요~ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | -- PL/SQL -- DECLARE CURSOR cur1 IS SELECT * FROM table2; BEGIN FOR c1 IN cur1 LOOP UPDATE table1 SET phone = c1.phone WHERE no = c1. no ; END LOOP; COMMIT ; EXCEPTION WHEN OTHERS THEN ROLLBACK ; END ; / -- One SQL -- UPDATE table1 t1 SET phone = ( SELECT phone FROM table2 t2 WHERE t2. no = t1. no ) ; |