4 Replies Latest reply: Jan 1, 2013 4:52 PM by fac586 RSS

    working with Apex collections

    Gor_Mahia
      All,
      My collection is not working as expected, what could be the issue here.
      This is what i did,

      1. I created a collection in a process to fire on page load

      if apex_collection.collection_exists(p_collection_name=>'MMMM') then
      apex_collection.delete_collection(p_collection_name=>'MMMM');
      end if;
      APEX_COLLECTION.CREATE_OR_TRUNCATE_COLLECTION(p_collection_name => 'MMMM');

      2. On my page i have a text field P1_text1 when i enter value into text field like ="sample data" i want this data loaded into my collection, so i created a button and added a process(on submit - before computations...) so it should insert into the collection when i click the button but no data is loaded,
      process:
      APEX_COLLECTION.ADD_MEMBER(
      p_collection_name => 'MMMM',
      p_c001 => :P1_TEXT1,
      p_c002 => 'TESTDATA' );


      3. when i run the below query it shows "no data found" ,

      SELECT c001,c002
      FROM APEX_COLLECTIONS
      WHERE collection_name = 'MMMM';


      thank you in advance.
        • 1. Re: working with Apex collections
          Gor_Mahia
          Apexers,
          I still need help on this Collections any suggestion any idea appreciated...regards.
          • 2. Re: working with Apex collections
            fac586
            Gor_Mahia wrote:

            My collection is not working as expected, what could be the issue here.
            This is what i did,

            1. I created a collection in a process to fire on page load
            Always post code using <tt>\
            ...\
            </tt> tags as described in the FAQ.
            if apex_collection.collection_exists(p_collection_name=>'MMMM') then
            apex_collection.delete_collection(p_collection_name=>'MMMM');
            end if;
            APEX_COLLECTION.CREATE_OR_TRUNCATE_COLLECTION(p_collection_name => 'MMMM');
            2. On my page i have a text field P1_text1 when i enter value into text field like ="sample data" i want this data loaded into my collection, so i created a button and added a process(on submit - before computations...) so it should insert into the collection when i click the button but no data is loaded,
            process:
            APEX_COLLECTION.ADD_MEMBER(
            p_collection_name => 'MMMM',
            p_c001            => :P1_TEXT1,
            p_c002            => 'TESTDATA' );
            3. when i run the below query it shows "no data found" ,
            SELECT c001,c002
            FROM APEX_COLLECTIONS
            WHERE collection_name = 'MMMM';
            Where do you run this query? If it's after a branch to the same page then obviously it shows no data because the page load process drops and recreates the collection if it exists. If it's outside of the current application session (for example, in the SQL Workshop or SQL Developer) then it shows no data because collections are session based. Use the session state viewer to inspect collections at runtime.
            • 3. Re: working with Apex collections
              Gor_Mahia
              fac586
              The query #3 below is running in my CLASSIC report region on the same page1 but this report doesnt display any data after i click the submit button as described in #2 above.
              SELECT c001,c002
              FROM APEX_COLLECTIONS
              WHERE collection_name = 'MMMM';
              alway "no data found"

              thank you.
              • 4. Re: working with Apex collections
                fac586
                Gor_Mahia wrote:

                The query #3 below is running in my CLASSIC report region on the same page1 but this report doesnt display any data after i click the submit button as described in #2 above.
                SELECT c001,c002
                FROM APEX_COLLECTIONS
                WHERE collection_name = 'MMMM';
                alway "no data found"
                Because the page load process always drops and recreates the collection if it exists:
                if apex_collection.collection_exists(p_collection_name=>'MMMM') then
                apex_collection.delete_collection(p_collection_name=>'MMMM');
                end if;
                APEX_COLLECTION.CREATE_OR_TRUNCATE_COLLECTION(p_collection_name => 'MMMM');
                What are you really trying to do?