1 Reply Latest reply on Apr 3, 2014 7:11 PM by odysam

    Trying to figure out APEX_ITEM.CHECKBOX2

    odysam

      Since yesterday I am trying to figure out checkboxes in APEX, which should be simple, however I have failed to make even the simplest scenario work.

      Here is what I did so you can tell me what I did wrong.

      I have three tables:

       

          create table semester(
            id number not null,
            name varchar2(30) not null,
            primary key(id)
          );
      
      
          create table subject(
            id number not null,
            name varchar2(30) not null,
            primary key(id)
          );
      
      
          create table semester_subject(
            id number not null,
            semester_id number not null,
            subject_id number not null,
            primary key(id),
            foreign key(semester_id) references semester(id),
            foreign key(subject_id) references subject(id),
            constraint semester_subject_uq unique(semester_id, subject_id)
          );
      

       

      I have created in apex a region with one select list with the following list of values:

       

          select name d, id r
          from semester
          order by 1
      

       

      and one report with the following query

       

          select 
            apex_item.checkbox2(10, id, 'UNCHECKED') "id",
            subject "Subject"
          from subject;
      

       

      Also I have one button to submit the page.

      What I want is to insert the ids of the subjects with the ticked checkboxes, in the semester_subject table, together with the id of the semester selected from the select list.

       

      So I made this on submit process:

       

          DECLARE
            v_subject_id subject.id%type;
            v_semester_id semester.id%type;
          BEGIN
            v_semester_id := :PX_SEMESTER;
            FOR I in 1..APEX_APPLICATION.G_F10.COUNT LOOP
              v_subject_id := APEX_APPLICATION.G_F10(i);
              insert into semester_subject(semester_id, subject_id)
                values(v_semester_id, v_subject_id); --I have a sequence and a trigger for the id
            END LOOP;
          END;
      

       

      On my VPS when I submit the page I get 404 error "The requested URL /apex/wwv_flow.accept was not found on this server".

      So I created a workspace on apex.oracle.com, there the page reloads and I get the success message from the process, but when I check the table semester subject, the data isn't inserted.

       

      Any ideas on what I'm doing wrong? Thanks in advance for your help.