Processing multiple select list item in oracle apex

Multiple select list or Shuttle item type returns selected items in a single colon-delimited sting.
e.g  When return value is id: 1:5:3
       When return value is string: val1:val3:val5
Examples:

1. Display employee details within the selected departments returned from a mulitselect list item/Shuttle item

 SELECT employee_name, job, salary, department_name
 FROM employee e, department d
 WHERE d.deptno = e.deptno
 AND instr(':'||:P19_DEPTNO||':',':'||e.deptno||':') > 0

2. Insert the selected values to a table from a multiselect list item/shuttle item

DECLARE
    l_selected_items APEX_APPLICATION_GLOBAL.VC_ARR2;
BEGIN
  
  l_selected_items := APEX_UTIL.STRING_TO_TABLE(:P19_DEPTNO);

  FOR i IN 1..l_selected.count 
  LOOP
    INSERT INTO log_table(create_date, selected_dept)
        VALUES (sysdate, l_selected_items(i));
  END LOOP;
END;

Comments