error:Invalid reference to variable 'PARTS1.PNUM%TYPE' - how to resolve
error:
ERROR at line 29:
ORA-06550: line 29, column 39:
PLS-00487: Invalid reference to variable 'PARTS1.PNUM%TYPE'
ORA-06550: line 29, column 4:
PL/SQL: SQL Statement ignored
DECLARE
cursor c1 is select pnum from parts1;
TYPE NumTab IS TABLE OF parts1.pnum%TYPE INDEX BY PLS_INTEGER;
TYPE NumTab1 IS TABLE OF parts1.pnum%TYPE INDEX BY PLS_INTEGER;
--TYPE NameTab IS TABLE OF parts1.pname%TYPE INDEX BY PLS_INTEGER;
pnums NumTab;
pnums1 NumTab1;
-- pnames NameTab;
--iterations CONSTANT PLS_INTEGER := 500;
t1 INTEGER;
t2 INTEGER;
t3 INTEGER;
l_num_index integer := 0;
BEGIN
FOR j IN 1..50000 LOOP -- load index-by tables
insert into parts1 values(j);
END LOOP;
commit;
t1 := DBMS_UTILITY.get_time;
/* FOR i IN 1..iterations LOOP -- use FOR loop
INSERT INTO parts1 VALUES (pnums(i));
END LOOP;
*/
select pnum bulk collect into pnums from parts1;
t2 := DBMS_UTILITY.get_time;
open c1;
loop
l_num_index := l_num_index + 1;
fetch c1 into pnums1(l_num_index).pnum;
EXIT WHEN c1%notfound;
end loop;
close c1;
t3 := DBMS_UTILITY.get_time;
DBMS_OUTPUT.PUT_LINE('Execution Time (secs)');
DBMS_OUTPUT.PUT_LINE('---------------------');
DBMS_OUTPUT.PUT_LINE('FOR loop: ' || TO_CHAR((t2 - t1)/100));
DBMS_OUTPUT.PUT_LINE('FORALL: ' || TO_CHAR((t3 - t2)/100));
COMMIT;
END;
/
thanks,
vinodh