I came across the following code in one website (I am providing the line numbers as well):
1. DECLARE
2. TYPE typePopulation IS TABLE OF NUMBER INDEX BY VARCHAR2(64);
3. tPopCountryPopulation typePopulation;
4. tPopContinentPopulation typePopulation;
5. iHowMany NUMBER;
6. strWhich VARCHAR2(64);
7. BEGIN
8. tPopCountryPopulation('Greenland'):=100000;
9. tPopCountryPopulation('Iceland'):=750000;
10. iHowMany:=tPopCountryPopulation('Greenland');
11.
12. tPopContinentPopulation('Australia'):=30000000;
13. tPopContinentPopulation('Antarctica'):=1000;
14. tPopContinentPopulation('Antarctica'):=1001;
15. strWhich:=tPopContinentPopulation.FIRST;
16. strWhich:=tPopContinentPopulation.LAST;
17. iHowMany:=tPopContinentPopulation(tPopContinentPopulation.LAST);
18. END;
19. /
I know that the 2nd line creates a TYPE named typePopulation but what does the statement IS TABLE OF NUMBER INDEX BY VARCHAR2(64) do? When the above is executed, the following errors are thrown:
PLS-00222: no function with name 'VARCHAR2' exists in this scope
which refers to line 2 in the above code &
PLS-00320: the declaration of the type of this expression is incomplete or malformed
which points to line 8, 9, 10, 12 & 13 in the above code. Why are the above errors getting generated? What's the solution to overcome for the above 2 errors?
Thanks,
Arpan
1. DECLARE
2. TYPE typePopulation IS TABLE OF NUMBER INDEX BY VARCHAR2(64);
3. tPopCountryPopulation typePopulation;
4. tPopContinentPopulation typePopulation;
5. iHowMany NUMBER;
6. strWhich VARCHAR2(64);
7. BEGIN
8. tPopCountryPopulation('Greenland'):=100000;
9. tPopCountryPopulation('Iceland'):=750000;
10. iHowMany:=tPopCountryPopulation('Greenland');
11.
12. tPopContinentPopulation('Australia'):=30000000;
13. tPopContinentPopulation('Antarctica'):=1000;
14. tPopContinentPopulation('Antarctica'):=1001;
15. strWhich:=tPopContinentPopulation.FIRST;
16. strWhich:=tPopContinentPopulation.LAST;
17. iHowMany:=tPopContinentPopulation(tPopContinentPopulation.LAST);
18. END;
19. /
I know that the 2nd line creates a TYPE named typePopulation but what does the statement IS TABLE OF NUMBER INDEX BY VARCHAR2(64) do? When the above is executed, the following errors are thrown:
PLS-00222: no function with name 'VARCHAR2' exists in this scope
which refers to line 2 in the above code &
PLS-00320: the declaration of the type of this expression is incomplete or malformed
which points to line 8, 9, 10, 12 & 13 in the above code. Why are the above errors getting generated? What's the solution to overcome for the above 2 errors?
Thanks,
Arpan