爲什麼Oracle在使用「rowid」時爲什麼使用「where current」語法?示例:PL/SQL「Where of Current of」vs「ROWID」
BEGIN
FOR rec IN (SELECT t.column1, t.rowid rid FROM test_table) LOOP
UPDATE test_table tb SET column1 = some_function(rec.column1) WHERE tb.rowid = rec.rid;
END LOOP;
COMMIT;
END;
DECLARE
CURSOR cur IS SELECT t.column1 FROM test_table;
param1 test_table.column1%TYPE;
BEGIN
LOOP
FETCH cur INTO param1;
UPDATE test_table tb SET tb.column1 = some_function(param1) WHERE CURRENT OF cur;
EXIT WHEN cur%NOTFOUND;
END LOOP;
COMMIT;
END;
Oracle提供了WHERE CURRENT OF子句來更新或刪除由會話中的FOR UPDATE OF遊標鎖定的行。 –