Search code examples
plsqloracle-apex

How to auto populate apex form field


I am creating a profile page in oracle apex and I am having troubles populating the form fields with values from the user table. I created a before header process with the plsql code

select user_id, fname, lname, email
into :P15_USER_ID, :P15_FNAME, :P15_LNAME, :P15_EMAIL
from user
where email = :APP_USER;

However, I got an error message saying no data was found and I can't seem to figure out why even after debugging. Any idea why this might happen?

Alternatively, I tried replacing :app_user with v('app_user') as well but the same thing happened.

If anyone has any references on how to autofill a form in apex it would be of great help to me as well. Thank you for any inputs in advance.


Solution

  • Most probably reason is that there is no record in the user table with a record where email exactly matches the value of :APP_USER. This means: (1) that case needs to be the same ('mickey.mouse@disney.com' is not the same as 'Mickey.Mouse@disney.com') and (2) there can not be any blanks in the email column (' mickey.mouse@disney.com' is not the same as 'mickey.mouse@disney.com'). So the question is: what value is there in the column email and what value is there in APP_USER ?

    As second possibility is that this no data found exception is not raised by the statement you posted but by another statement. This should be visible in debug.

    Note: in the context of an apex session, :APP_USER and v('APP_USER') should have identical values. The only difference is that the 'v' function fetches the value from the apex session metadata and the :APP_USER is a native pl/sql bind variable (and is more performant).