Search code examples
plsqloracle-apex-5

Apex Shuttle adds multple items into single column


I am having issues with my Shuttle service on Apex 5.

Currently I have a process assigned to my submit button after multiple selection on a shuttle service. The shuttle layout is as per below:

a part has many part_names that can be selected. So the part is the main feature and only occur once. i.e:

part - part_name1
       part_name2
       part_name3
       part_name4

let's say we select part_names part_name1 and part_name3 in the shuttle, plsql code should then add each selection and add them to separate rows, but keep replicating part and the other fields, but currently it will add a single part, with multple part_names per column.

The process plsql code:

begin
insert into service_group (UNIQUEID, PART, PART_NAME, SERVICE) 
values (:P115_UID, :P115_PART, :P115_PART_NAMES, :P115_SERVICE);
end;

EXPECTED Result:

UID1 | part | part_name1 | Service1
UID2 | part | part_name3 | Service1

CURRENT Result (Wrong)

UID1 | part | part_name1:part_name3 | Service1

Please can someone help me to get each in a separate row instead of combined in columns.


Solution

  • You need to use apex_string.split to get the individual values out of the shuttle item:

    declare
       l_part_names apex_t_varchar2;
    begin
       l_part_names := apex_string.split (:P115_PART_NAMES, ':');
       for i in 1..l_part_names.count loop
          insert into service_group (UNIQUEID, PART, PART_NAME, SERVICE) 
          values (:P115_UID, :P115_PART, l_part_names(i), :P115_SERVICE);
       end loop;
    end;