How can I emulate Oracle Forms’ POST-NEXT-RECORD behavior in Oracle APEX so that changing an item triggers a database lookup and fills other items without a page submit or reload?
Specifically, I want a Dynamic Action on the Change event of :TESTID
that runs a PL/SQL block to fetch the test price and its discount from MEDICAL_CENTER_SYSTEM.LAB_SEC_L_TESTS
and then assigns them to two items on the same record/row (no page refresh). Here is the PL/SQL I want to execute:
DECLARE
v_price NUMBER;
v_discount NUMBER;
BEGIN
SELECT PRICE, DISCOUNT_TEST
INTO v_price, v_discount
FROM MEDICAL_CENTER_SYSTEM.LAB_SEC_L_TESTS
WHERE TESTID = :TESTID;
-- set values in the same row
:PRICE_TEST_CONST := v_price;
:DISCOUNTS := v_discount;
-- or set values by use set_session_state
apex_util.set_session_state('PRICE_TEST_CONST', v_price);
apex_util.set_session_state('DISCOUNTS', v_discount);
EXCEPTION
WHEN NO_DATA_FOUND THEN
:PRICE_TEST_CONST := NULL;
:DISCOUNTS := NULL;
END;
