it's the rename procedure that's broken
procedure rename (
item_id in cr_items.item_id%TYPE,
name in cr_items.name%TYPE
) is
v_item_id cr_items.item_id%TYPE;
v_name cr_items.name%TYPE;
cursor exists_cur is
select
item_id
from
cr_items
where
cr_items.name = v_name
and
parent_id = (select
parent_id
from
cr_items
where
cr_items.item_id = v_item_id);
exists_id integer;
begin
open exists_cur;
fetch exists_cur into exists_id;
if exists_cur%NOTFOUND then
close exists_cur;
update cr_items
set cr_items.name = v_name
where cr_items.item_id = v_item_id;
else
close exists_cur;
if exists_id <> item_id then
raise_application_error(-20000,
'An item with the name ' || name ||
' already exists in this directory.');
end if;
end if;
end rename;