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:
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;