The code block below is not running when executed from a batch file. It just hangs (nothing happens). It sits there for hours. I am unable to track what the problem is or how to debug this. Please help.
declare
v_personrefid varchar2(50);
v_hiredt date;
v_loaddt date;
v_personid number;
v1_personrefid varchar2(50);
v_seq number :=0;
cursor get_row is
select distinct personrefid from ARCHIVE_PERSON;
cursor get_row1 is
select
personrefid,
hiredt,
loaddt,
personid
from
ARCHIVE_PERSON
where
personrefid = v_personrefid
order by hiredt, loaddt;
begin
v_seq:=0;
open Get_row;
loop
fetch get_row into v_personrefid ;
exit when get_row%notfound;
begin
open get_row1;
loop
fetch get_row1 into v1_personrefid, v_hiredt, v_loaddt, v_personid;
exit when get_row1%NOTFOUND;
v_seq:= v_seq+1;
update ARCHIVE_PERSON
set version = v_seq
where
personrefid = v1_personrefid and
personid = v_personid and
hiredt = v_hiredt and
loaddt = v_loaddt;
commit;
end loop;
v_seq:=0;
close get_row1;
end;
end loop;
v_seq:=0;
close get_row;
end;
One possibility is that you don’t have a slash
/in your script following theend;statement, which would tell SQLPlus to execute the block. If you simply haveend;followed by nothing, SQLPlus may be waiting for more input that it will never get.Aside from that, I’d suggest having your dba look at
V$SESSION_WAITwhile the block is running to see what your session is waiting on.Moreover, you might try a rewrite like the following, which I think will be more efficient: