declare
i int := 1;
cursor c_cur is select * from logcost_tmp for update;
begin
open c_cur;
loop
update logcost_tmp set lgcicode = to_char(1000000000010901-i) where current of c_cur;
i:=i+1;
end loop;
close c_cur;
commit;
end;
报错:ORA-01410:invalid ROWID
ORA-06512: at line 7
i int := 1;
cursor c_cur is select * from logcost_tmp for update;
begin
open c_cur;
loop
update logcost_tmp set lgcicode = to_char(1000000000010901-i) where current of c_cur;
i:=i+1;
end loop;
close c_cur;
commit;
end;
报错:ORA-01410:invalid ROWID
ORA-06512: at line 7
所有报无效rowid
2、没有exit,是个死循环。
DECLARE
i INT := 1;
CURSOR c_cur IS
SELECT * FROM logcost_tmp FOR UPDATE;
r_logcost_tmp logcost_tmp%ROWTYPE;
BEGIN
OPEN c_cur;
LOOP
FETCH c_cur INTO r_logcost_tmp;
EXIT WHEN c_cur%NOTFOUND;
UPDATE logcost_tmp
SET lgcicode = to_char(1000000000010901 - i)
WHERE CURRENT OF c_cur;
i := i + 1;
END LOOP;
CLOSE c_cur;
COMMIT;
END;
/
/*
ORA-01410 invalid ROWID
Cause: A ROWID was entered incorrectly.
ROWIDs must be entered as formatted hexadecimal strings using only numbers
and the characters A through F. A typical ROWID format is '000001F8.0001.0006'.Action: Check the format, then enter the ROWID using the correct format.
ROWID format: block ID, row in block, file ID.
*/