Pumayk26
Pumayk26

Reputation: 565

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..?

Upvotes: 0

Views: 2254

Answers (2)

Koen Lostrie
Koen Lostrie

Reputation: 18665

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:

  • Create a form on emp
  • Make P1_EMPNO the primary key page item
  • Suppose you create a new row, and that empno value is 1000. Then after the automatic row processing page process is run, the value of P1_EMPNO is set to 1000.

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.

Upvotes: 3

Littlefoot
Littlefoot

Reputation: 142733

Instead of a database trigger, use a stored procedure which will do the same job. Pass any number of parameters you want (including the P500_SOMEIDS item).

Upvotes: 1

Related Questions