Store 12 months in varray of string
SQL> DECLARE
2 TYPE months_varray IS VARRAY(12) OF STRING(9 CHAR);
3
4 TYPE calendar_table IS TABLE OF VARCHAR2(9 CHAR) INDEX BY BINARY_INTEGER;
5
6 month MONTHS_VARRAY := months_varray('January','February','March','April','May','June','July','August','September','October','November','December');
7
8 calendar CALENDAR_TABLE;
9 BEGIN
10 IF calendar.COUNT = 0 THEN
11 FOR i IN month.FIRST..month.LAST LOOP
12 calendar(i) := '';
13 DBMS_OUTPUT.PUT_LINE(i||' is '||calendar(i));
14 calendar(i) := month(i);
15 END LOOP;
16
17
18 END IF;
19 END;
20 /
1 is
2 is
3 is
4 is
5 is
6 is
7 is
8 is
9 is
10 is
11 is
12 is
PL/SQL procedure successfully completed.
SQL>
Related examples in the same category