Oracle Apex PL/SQL Expression Example

In this post, I am giving the Oracle Apex PL/SQL expression example to validate a text field. Not only for validation, but you can also use the PL/SQL expressions for more purposes in Oracle Apex.

Oracle Apex PL/SQL Expression Example

In the below example, it is creating validation for the SAL column, which must be greater than 1000.

To create the PL/SQL expression for the SAL column, select the SAL field in the content body region and do the right click on it and select Create Validation option.

In the Validation section, select the type as PL/SQL Expression and then in the text area enter :sal > 1000 as shown in the below image:

Oracle Apex Validation Section.
Illustrating PL/SQL expression to validate a text field in Oracle Apex. Image by FoxInfotech.

Now if the condition evaluates to TRUE, means the SAL is > 1000 then it is OK; else it will raise the error.

Oracle Apex PL/SQL Function Body (Returning boolean) Example

You can write the above condition for type PL/SQL Function Body (returning boolean) as well. To write the validation as demonstrated above, enter the following code into the text area, as shown below:

Begin
  if :sal > 1000 then
     return true;
  else
     return false;
  end if;
end;

See also:

Vinish Kapoor
Vinish Kapoor

Vinish Kapoor is a seasoned software development professional and a fervent enthusiast of artificial intelligence (AI). His impressive career spans over 20 years, marked by a relentless pursuit of innovation and excellence in the field of information technology. As an Oracle ACE, Vinish has distinguished himself as a leading expert in Oracle technologies, a title awarded to individuals who have demonstrated their deep commitment, leadership, and expertise in the Oracle community.