oracletriggersoracle-apexapex-triggeroracle-apex-19.2

Access "Page Items to Submit" values inside a trigger in oracle apex


I want to access extra page item value from a trigger which isn't in the related data table. For an example I have a table like below,

      Employee
----------------------

empId | fName | lName 
----------------------
1     | John  | Doe
----------------------
2     | Jane  | Doe 

Apex form items will be like,

P500_EMPID, P500_FNAME, P500_LNAME

I have an extra page item called P500_SOMEIDSwhich is a multi select list. I want to access those selected values inside After Insert trigger of the Employee table. I tried to add this item into "Page Items to Submit". But I do not know how to access it inside that trigger. Is it possible..? and How..?


Solution

  • In the page process that handles your table update (that will be a process of type "Form - Automatic Row Processing (DML)", under "Settings" there is a attribute "Return Primary Key(s) after Insert". If that is set to "On", then the insert statement will return the value of the inserted row into the page item that is defined as your primary key. Example:

    If you want to insert rows into another table referencing the newly created empno then you can create a page process (that executes after the row processing) of type pl/sql code like this:

    BEGIN
      INSERT INTO some_other_table (empno) VALUES (:P1_EMPNO); 
    END;
    

    Using triggers for business functionality should be avoided whenever possible.