8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » Misc » Here

APEX Tips : Call PL/SQL Code Using a Dynamic Action

Dynamic actions allow you to break out of the normal page submit flow to perform actions, but you need to understand session state. Some actions will only reference item values in session state, which may not be what you are trying to use. In this example we will use a PL/SQL dynamic action.

Related articles.

Setup

We have a table with the following structure.

CREATE TABLE t1 (
  code VARCHAR2(10)
);

Create and item on the page with the following details.

Name: P1_LIST
Type: Select List
LOV Type: Static Values
Static Values: One, ONE, Two, TWO
Display Extra Values: No
Display Null Value: No

In the dynamic action tab we create a new dynamic action under the "Change" event, with an action under "True".

Name: P1_LIST_CHANGE
Event: Change
Selection Type: Item(s)
Item(s): P1_LIST

Action: Execute PL/SQL Code
PL/SQL Code:

BEGIN
  INSERT INTO t1 VALUES (:P1_LIST);
  COMMIT;
END;

Items to Submit: {null}

Testing

When you run the application, changes to the list will trigger the dynamic action, but it will keep inserting the value in session state. It won't insert the changed value. In this example, every change will result in the value "ONE" being inserted into the table.

Go back to the dynamic action, and set the "True" action as follows.

Items to Submit: P1_LIST

Rerun the application. You will find any change to the list item results in the selected value being used for the insert, and set in the session state, without a submit of the whole page. In this example, the values "TWO" and "ONE" are inserted into the table, as the list value changes.

For more information see:

Hope this helps. Regards Tim...

Back to the Top.