oracle-databaseoracle-apex

Fetching Data from Database on Form Rendering Oracle APEX 24


I have an oracle apex form version 24 . i have a user ID and i need to fetch his name and put it in an item on the screen . what is the proper way to do so ?

I am new to this technology.

i did try dynamic actions but it didn't work i don't know if it is the proper way to do so.

the dynamic action code

select emp_num
INTO :P3_EMP_NUM
from HR_EMPLOYEES
where EMP_ID = :P3_EMP_ID

RETURN :P3_EMP_NUM;

-- NOTE THIS WAS A PL/SQL FUNCTION BODY TYPE

Solution

  • In Apex, a form page is rarely standalone; it is usually called from an interactive report (IR) page via "Create" or "Edit" buttons:

    You said that you have user ID, so I'll presume that it is the 2nd case.

    If that's so, one way to do what you want is to modify ID item to be a Select List item. It uses List of Values - in your case, you'd use query, e.g.

    select emp_name as display_value,
           emp_id   as return_value
    from hr_employees
    

    which then automatically displays employee name (instead of its ID). If you want to display ID as well, concatenate it to emp_name.


    On the other hand, if you - for some reason - manually enter ID into the form item, create dynamic action (DA) on it so that when its value changes, a Set Value DA will populate the name item.

    select emp_name 
    from hr_employees
    where emp_id = :P3_EMP_ID;
    

    Make sure to put P3_EMP_ID into "Items to submit" property; affected element is item named P3_NAME.

    enter image description here