简体   繁体   中英

Oracle APEX PL/SQL process to insert multi-select items into association table for m:m relationship failing silently

I am implementing a form on table that allows the end-user to create a new project. This form contains a shuttle that allows the user to select the disposal site(s)(1+) that the project pertains to. I would like to use the output of the shuttle values to populate an association table between projects and disposal sites which is a many to many relationship.

This is my approach so far:

  1. Created an additional VARCHAR2(4000)in the projects table to store the shuttle output (called 'Shuttle'). The shuttle output in this column looks something like 'CA-AT-D109Z2:CA-AT-D115:CA-AT-D174Z2'.
  2. Created a process to take separate based on ':' and then add the values to the association table using the PL/SQL code:
Declare
  Cursor c_values
   is 
  Select
    t.column_value As disposal_sites
  From
     Table ( apex_string.split(:P28_SHUTTLE, ':') ) t
  Where
     t.column_value Is Not Null;
Begin
  for c in c_values loop
     insert into MP_MDB_PROJECT_2_DSITE (PROJECTIDFK,DISPOSALSITEIDFK)
       values (:P28_PROJECTNUMBER,c.disposal_sites);
  end loop;
End;

The process/code enters the values from the shuttle into the association table in a loop as expected for the the disposal site but remains blank for projectidfk (the key that is '1' in the 1:m relationship). The code doesn't throw an error so I am having trouble debugging.

I think perhaps the problem I am having is that project number is computed after submission based on the users selections.Therefore, when the process run it finds:P28_PROJECTNUMBER to be null. Is there a way to ensure the computation to determine:P28_PROJECTNUMBER takes places first and is then followed by the PL/SQL process?

All help appreciated

在此处输入图像描述

If the form you're implementing is a native apex form, then you can use the attribute "Return Primary Key(s) after Insert" in the "Automatic Row Processing - DML" process to ensure that the primary key page item contains inserted value for any processes execute after this process.

在此处输入图像描述

Just make sure the process that handles the shuttle data is executed after the DML process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM