4 Replies Latest reply: Sep 10, 2013 7:11 AM by vdsadhi RSS

    Delimited String To A Single Row Within A Table

    9fe1bd69-ad38-4d48-937e-fda1917c50da

      I'll try to make a simple example of what I am trying to accomplish...

       

      Let's say that I have a table (Blah) which has the following Fields:

      User, DateTime, Q1, Q2.... all the way to Q50.  The Questions are radios with a value of 1,0, or null.

       

       

      Since I didn't want to manually make 50 different items for the Radio questions, I am creating them from Javascript within a Region Source; as well as giving them id's and names.  This worked fine.

       

      When I hit a submit button, I have Javascript create a delimited string for the questions, which I pass to a Shared Item.  (1,0,1,1,null,0,etc...)  I then have the Javascript run a Shared Procedure for the Insert into my Table.

       

      Here is where I am stuck.  I am confused on how to merge the delimited string into my Insert statement, from PL/SQL.

       

      Here is a dummied down sample of what I am trying to write.  (Shared Item is :ITEM_ARRAY, with a delimiter of ~:~ )

       

      DECLARE

          array APEX_APPLICATION_GLOBAL.VC_ARR2

      ;

       

      BEGIN

       

          array := APEX_UTIL.STRING_TO_TABLE(:ITEM_ARRAY, ':~:' );

       

          INSERT INTO tbl_blah (

              :APP_USER

              ,SYSDATE

               FOR z IN 1..array.count LOOP

                   array(z);

               END LOOP;

          );

       

      END;

       

      Every which way I tried, I always get Not Enough Values Error.

      I tried to make everything in a delimited string as well:

      Insert Into tbl_blah (SELECT * FROM array)

       

      Can someone please enlighten me on the correct way to do this.  All of the examples I have seen are to write to multiple rows, via the loop.  I want to just have 1 record, horizontally.

       

      Thanks !!!