Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Build Html table from a collection with pl-sql

GonçaloFeb 6 2021 — edited Feb 6 2021

Hello,
I have a table of records of this type where i stored a collection:
TYPE TABLE_RECORD IS RECORD (n_lin number, n_col number, val varchar(4000)); TYPE TABLE_CHUNK IS TABLE OF TABLE_RECORD;
Let imagine i have this records inside:

-- 1 0 DATA
-- 1 1 UGW
-- 1 2 500
-- 2 0 DATA
-- 2 1 Teste
-- 2 2 100
The first is the line number,the second is the column number and the third the value.
I want to loop all the collection and build the table body in html, but the number of columns in the head can be variable so i never know how many static <td> i will have . For the head i loop a table that contain all the clauses for the select statement so its more easy.



l_columns_data DYNAMIC_TABLE.TABLE_CHUNK :=DYNAMIC_TABLE.TABLE_CHUNK();

htp.p(' <tbody>');


       FOR j IN 1..l_columns_data.COUNT LOOP
           
           
 
           htp.p( ' <tr>');
             

              htp.p('<td> '||l_columns_data(j).val||'</td>');
                  

             
                
            htp.p('</tr>');
           
            end loop;
           
           
htp.p( '</tbody>
        </table>
        ');


The objective is that ever 3 rows from the collection that has the line number "1" create a row in the table <tr> and then accordingly with the number of columns create a correspondent <td> with the associated value.
You know how can i achieve this?
Thanks.

APEX Version: 20
Database Version: 18C

This post has been answered by Gonçalo on Feb 6 2021
Jump to Answer

Comments

Post Details

Added on Feb 6 2021
5 comments
3,659 views