SQL> CREATE OR REPLACE procedure recTypeProc 2 IS 3 TYPE recType is RECORD ( 4 ename EMP.ename%TYPE, 5 sal EMP.sal%TYPE); 6 7 TYPE recTabType is TABLE of recType 8 INDEX by BINARY_INTEGER; 9 recTab recTabType; 10 bNew BINARY_INTEGER; 11 BEGIN 12 recTab(3).ename := 'Hi'; 13 recTab(3).sal := 1000; 14 recTab(7).ename := 'Hello'; 15 recTab(7).sal := 2000; 16 recTab(200).ename := 'Ciao'; 17 recTab(200).sal := 4000; 18 19 print (recTab(recTab.First).ename); 20 print (recTab(recTab.Next(3)).ename); 21 print (recTab.Prior(recTab.Last)); 22 print (recTab.Next(recTab.Prior(recTab.Last))); 23 24 print(CHR(10) || `PL/SQL FOR LOOP' || CHR(10)); 25 26 FOR bInt IN recTab.FIRST .. recTab.LAST LOOP 27 IF recTab.EXISTS(bInt) THEN 28 Print(bInt || ` ` || recTab(bInt).ename); 29 END IF; 30 END LOOP; 31 32 print(CHR(10) || `PL/SQL NEXT LOOP' || CHR(10)); 33 34 bNew := recTab.FIRST; 35 Print( bNew || ` ` || recTab(bNew).ename ); 36 LOOP 37 bNew := recTab.NEXT(bNew); 38 Print( bNew || ` ` || recTab(bNew).ename ); 39 EXIT WHEN bNew = recTab.LAST; 40 END LOOP; 41 END 42 /
Warning: Procedure created with compilation errors.
SQL> execute recTypeProc;
BEGIN recTypeProc; END;
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00905: object SYSTEM.RECTYPEPROC is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
SQL> CREATE OR REPLACE procedure recTypeProc 2 IS 3 TYPE recType is RECORD ( 4 ename EMP.ename%TYPE, 5 sal EMP.sal%TYPE); 6 7 TYPE recTabType is TABLE of recType 8 INDEX by BINARY_INTEGER; 9