Hi,
A beginner needs some help:
There are two items on a page. User enters EMP_ID and the second (display) item shows emp_name.
I marked EMP_ID as "sumbit when Enter is pressed", and create an after-submit process with the simple code:
select emp_name from emps where emp_id = P1_EMP_ID ... and it works.
Now, when the user enters a nonexistent ID, I need to display an error message and clear P1_emp_name (which has a value from previous query.)
So, in my process I add:
exception when no_data_found then
P1_emp_name := null;
APEX_ERROR.ADD_ERROR (
p_message => 'No employees with this ID',
p_display_location => apex_error.c_inline_with_field,
p_page_item_name => 'P1_EMP_ID');
and the error message is shown but the previous value in NAME remains! It is essential for me to clear this item because in my real application there are like 15 items to be cleared and user is confused if they retain values from a previous search.
If I omit the apex_error function, then it is cleared. So the function somehow prevents other actions in the exception block. Seems it does get cleared in the session state, but page render does not happen once the eroor is shown?
I know there are workarounds, like creating hidden message item and set "p1_emp_name is null" in server side condition to display it if the name is empty, but it sounds like very bad practice.
What would be an elegant and correct way to do it?
Thanks
Daniel