Der All
I'm coding PL/SQL in Oracle DB 11g and I'm using multidimensional collections. After populating a variable v_freedays which is a two-dimension type I need to know the number of elements of that. If I use the method COUNT in the form v_freedays.COUNT it returns only the number of elements of the first dimension.
The data types involved in my code are :
CURSOR Get_Days_of_Project IS
SELECT proj_name, strt_date, end_date, total_months, total_freedays,
FROM Tproject ;
T_Days IS TABLE OF Get_Days_of_Project%ROWTYPE INDEX BY PLS_INTEGER;
T_Matrix IS TABLE OF T_Days INDEX BY PLS_INTEGER;
v_Days T_Days ;
v_freedays T_Matrix;
BEGIN
OPEN Get_Days_of_Project;
FETCH Get_Days_of_Project BULK COLLECT INTO v_Days
FOR idxmonth IN 1..100 -- FIRST DIMENSON will have 100 elements months and its corresponding freedays in each month
LOOP
FOR idxdays IN 1..V_days.Count -- SECOND DIMENSION will have 45 elements corresponding to the lines returned by the cursor
LOOP
v_freedays(idxmonth)(idxdays).totalfreedays := v_days.totalfreedays;
END LOOP;
END LOOP;
/* Althoug this code could not make any sense , the point here is that , at the end, v_matrix is correctly populated and it works */
/* The issue now is how to get the total number of elements of this matrix . 100 * 45 = 4500 */
DBMS_OUTPUT.PUT_LINE('Elements of Matrix v_matrix : '|| v_freedays.count);
END;
Returned :
Elements of Matrix v_matrix : 100
I tried v_freedays() ().count , but I got the compilation error :
- PLS-00355: use of pl/sql table not allowed in this context
Does anyone knows how to get the total number of elements of a multidimensional collection ?
Preferable, is it posible to know the number of elements of each dimension ?
I appreciate your help ! Thks !
Ricardo.