Skip to Main Content

SQL & PL/SQL

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!

Take Oracle Type Array and Insert Contents into an Oracle Table

Tony FatourosAug 21 2019 — edited Aug 22 2019

Hi,

Hoping someone can assist with the following:

I have a variable l_rec of type wwv_flow_global.vc_arr2 within my package procedure, where:

type vc_arr2 is table of varchar2(32767) index by binary_integer;

Within l_rec, I have populated a number of records.

Within my debug statement, I can access the records using the following query:

   FOR i IN 1..l_rec.COUNT

    LOOP

      insert into msg_log(msg)

      values

        ('Record info: Index: ' || i || ' - Value: ' || l_rec(i));

    END LOOP;

FYI, I actually also have an outer loop that repeats the below info but with different data, i.e. a loop within a loop.

Sample dataset looks like:

Record info: Index: 1 - Value: AA

Record info: Index: 2 - Value: BB

Record info: Index: 3 - Value: CC

Record info: Index: 4 - Value: DD

Record info: Index: 5 - Value: EE

Record info: Index: 1 - Value: AAA

Record info: Index: 2 - Value: BBB

Record info: Index: 3 - Value: CCC

Record info: Index: 4 - Value: DDD

Record info: Index: 5 - Value: EEE

etc....

Based on the above, I have created a table called message_log that has the following columns:

SEQ_ID  NUMBER,

C001    VARCHAR2(4000),

C002    VARCHAR2(4000),

C003    VARCHAR2(4000),

C004    VARCHAR2(4000),

C005    VARCHAR2(4000)

My question is, how can I take my l_rec array of type wwv_flow_global.vc_arr2 and insert the whole contents into my message_log Oracle table?

Please note that SEQ_ID here will be a counter of my outer loop so I would expect to see message log table data as follows:

1,AA,BB,CC,DD,EE

2,AAA,BBB,CCC,DDD,EEE

Any help on how to achieve this, would be great.

Thanks.

Tony.

Comments
Post Details
Added on Aug 21 2019
5 comments
1,804 views