Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
CREATE OR REPLACE PACKAGE TABLE_TYPES
AS
TYPE tNumber IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
TYPE tString IS TABLE OF VARCHAR2(250) INDEX BY BINARY_INTEGER;
END;
DECLARE
tab TABLE_TYPE.tNumber;
BEGIN
tab(1) := 30;
tab(30) := 1;
tab(2) := tab(30) - tab(1);
DBMS_OUTPUT.ENABLE();
DBMS_OUTPUT.PUT_LINE('Index two contains: ' || tab(2));
END;
Index two contains: -29
PL/SQL procedure successfully completed.
1. CREATE OR REPLACE PACKAGE EXAMPLE_PKG AS
2. FUNCTION myFunction() RETURN TABLE_TYPES.tNumber;
3. PRAGMA RESTRICT_REFERENCES(myFunction,WNDS);
4. END;
5. /
1. CREATE OR REPLACE PACKAGE BODY EXAMPLE_PKG AS
2. FUNCTION myFunction() RETURN tNumber
3. -- this function returns a table of numbers 1 to 10
4. IS
5. example_table TABLE_TYPES.tNumber;
6. BEGIN
7. FOR indx IN 1 .. 10
8. LOOP
9. example_table(indx) := i;
10. END LOOP;
11. END;
12. /
1. DECLARE
2. tab TABLE_TYPES.tNumber;
3. BEGIN
4. tab := EXAMPLE_PKG.myFunction();
5. DBMS_OUTPUT.ENABLE();
6. for i in 1 .. tab.COUNT
7. LOOP
8. DBMS_OUTPUT.PUT_LINE('Row ' || i || '. value = ' || tab(i));
9. END LOOP;
10.END;