6 Replies Latest reply: Mar 7, 2013 8:59 AM by siegwin.port RSS

    Using apex_item.checkbox

    siegwin.port
      Hi,
      I got problems, using APRX_ITEM.CHECKBOX in AP$EX 4.2. This is my select statement:
      select apex_item.checkbox(8,department_id,NULL) chk,
      apex_item.text(9,department_name) department_name,
      apex_item.text(10,manager_id) manager_id,
      apex_item.text(11,location_id) location_id,
      apex_item.text(12,department_id) dept
      from departments
      where location_id = :P5_LOC;

      The result is 27 records.

      "DEPARTMENT_ID"     "DEPARTMENT_NAME"     "MANAGER_ID"     "LOCATION_ID"
      10     "Administration"     200     1700
      30     "Purchasing"     114     1700
      90     "Executive"     100     1700
      100     "Finance"     108     1700
      110     "Accounting"     205     1700
      120     "Treasury"          1700
      130     "Corporate Tax"          1700
      140     "Control And Credit"          1700
      150     "Shareholder Services"          1700
      160     "Benefits"          1700
      170     "Manufacturing"          1700
      180     "Construction"          1700
      190     "Contracting"          1700
      200     "Operations"          1700
      210     "IT Support"          1700
      220     "NOC"          1700
      230     "IT Helpdesk"          1700
      240     "Government Sales"          1700
      250     "Retail Sales"          1700
      260     "Recruiting"          1700
      270     "Payroll"          1700



      Then I changed the records 1,3,5.
      After pressing the update Button, only 2 records are correctly changed.
      This ist the update process:
      declare
      zahl number;
      type rec is record (id number, wert varchar2(2000));
      type tab is table of rec index by binARY_INTEGER;
      tab_1 tab;
      begin
      tab_1.delete;
      zahl := APEX_APPLICATION.G_F08.count;
      insert into tt values('gesamt='||zahl);
      commit;
      FOR i IN 1..APEX_APPLICATION.G_F08.COUNT LOOP
      tab_1(i).id := APEX_APPLICATION.G_F08(i);
      tab_1(i).wert := APEX_APPLICATION.G_F09(i);
      end loop;
      for i in 1 ..tab_1.count loop
      insert into tt values('I='||i||' id='||tab_1(i).id||
      ' wert='||tab_1(i).wert);

      /*update departments
      set department_name = APEX_APPLICATION.G_F09(i) --,
      -- manager_id = APEX_APPLICATION.G_F10(i)
      where department_id = zahl;*/

      end loop;
      commit;
      end;

      The result of the debug table tt is:

      "gesamt=3"
      "I=1 id=10 wert=Administration 1"
      "I=2 id=90 wert=Purchasing"
      "I=3 id=110 wert=Executive 2"

      You see, the record 2 originally is id=30, the changed record id is right 90 but the value of wert in my update procedure is Purchasing and not Executive 2. The id of record 3 is correct 110, the value of the record is Executive2 and not Accounting 3. I think I'm using always the same row.
      Please help me
      Regards
      Siegwin
        • 1. Re: Using apex_item.checkbox
          Denes Kubicek
          This example may help you:

          https://apex.oracle.com/pls/apex/f?p=31517:95

          Denes Kubicek
          -------------------------------------------------------------------
          http://deneskubicek.blogspot.com/
          http://www.apress.com/9781430235125
          http://apex.oracle.com/pls/apex/f?p=31517:1
          http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
          -------------------------------------------------------------------
          • 2. Re: Using apex_item.checkbox
            siegwin.port
            Thank you,
            but this example did not rerally help me. My problem is not the select statement, it is the update process. The select statement returns all records to the front.
            You see, that the id's of the changed records arre correct but only the changed value is correct, the others are wrong.
            Regards
            Siegwin
            • 3. Re: Using apex_item.checkbox
              Denes Kubicek
              The example is about the update process and not about the select statement. I am sure, your problem is solved if you once again have a look at my example.

              Denes Kubicek
              -------------------------------------------------------------------
              http://deneskubicek.blogspot.com/
              http://www.apress.com/9781430235125
              http://apex.oracle.com/pls/apex/f?p=31517:1
              http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
              -------------------------------------------------------------------
              • 4. Re: Using apex_item.checkbox
                siegwin.port
                Thank you, but I cannot understand this procedure and my problem:
                DECLARE
                q VARCHAR2 (1000);
                BEGIN
                q := q || 'SELECT deptno, DECODE(deptno, ';
                q := q || '10, ''<img src=" #IMAGE_PREFIX#bullet1.gif" >'',';
                q := q || '20, ''<img src=" #IMAGE_PREFIX#bullet2.gif" >'',';
                q := q || '30, ''<img src=" #IMAGE_PREFIX#bullet3.gif" >'',';
                q := q || '40, ''<img src=" #IMAGE_PREFIX#bullet4.gif" >'') ';
                q :=
                q
                || 'image, ''<span title="'' || dname || ''">'' '
                || '|| dname || ''</span>'' dname FROM DEPT ';
                q :=
                q
                || 'WHERE CASE WHEN TO_NUMBER (:p1_dept) != -1 '
                || 'THEN deptno ELSE 1 END = CASE WHEN '
                || 'TO_NUMBER (:p1_dept) != -1 THEN TO_NUMBER (:p1_dept) '
                || 'ELSE 1 END';
                RETURN (q);
                END;

                And I do not unterstand this submit process to update some rows
                BEGIN
                :p1_deptno := NULL;
                END;

                Condition
                BEGIN
                IF :request != 'SET_DEPT'
                THEN
                RETURN TRUE;
                ELSE
                RETURN FALSE;
                END IF;
                END;

                Sorry, please explai it
                • 5. Re: Using apex_item.checkbox
                  siegwin.port
                  Thank you, but I cannot understand this procedure and my problem:
                  DECLARE
                  q VARCHAR2 (1000);
                  BEGIN
                  q := q || 'SELECT deptno, DECODE(deptno, ';
                  q := q || '10, ''<img src=" #IMAGE_PREFIX#bullet1.gif" >'',';
                  q := q || '20, ''<img src=" #IMAGE_PREFIX#bullet2.gif" >'',';
                  q := q || '30, ''<img src=" #IMAGE_PREFIX#bullet3.gif" >'',';
                  q := q || '40, ''<img src=" #IMAGE_PREFIX#bullet4.gif" >'') ';
                  q :=
                  q
                  || 'image, ''<span title="'' || dname || ''">'' '
                  || '|| dname || ''</span>'' dname FROM DEPT ';
                  q :=
                  q
                  || 'WHERE CASE WHEN TO_NUMBER (:p1_dept) != -1 '
                  || 'THEN deptno ELSE 1 END = CASE WHEN '
                  || 'TO_NUMBER (:p1_dept) != -1 THEN TO_NUMBER (:p1_dept) '
                  || 'ELSE 1 END';
                  RETURN (q);
                  END;

                  And I do not unterstand this submit process to update some rows
                  BEGIN
                  :p1_deptno := NULL;
                  END;

                  Condition
                  BEGIN
                  IF :request != 'SET_DEPT'
                  THEN
                  RETURN TRUE;
                  ELSE
                  RETURN FALSE;
                  END IF;
                  END;

                  Sorry, please explai it
                  • 6. Re: Using apex_item.checkbox
                    siegwin.port
                    Hello,
                    I have my application transferred to apex.oracle.com with the login pos_schulung and user demo/demo Select application Id 45537 - demo_application
                    If you us the list knot Länder and select US you will com to the page 5 Please select there Washington with the right Icon.
                    There will be a report displayed. Change Department Name on department 10,90 and 110 and select the 3 checkboxes. If you send page with buttonxx ther are the results in the table tt and no updates in table departments because there are mistakes.
                    The process is chk_bx which takes the right ids and the wron departments.
                    Please help me again
                    Regards
                    Siegwin