Server-side validations in Oracle APEX run on page submit, before any page processing takes place. When a validation fails, APEX stops execution, displays the error message inline next to the failing field (and in the notification area), and does not execute any page processes. This makes validations the correct place to enforce data integrity rules — not inside the DML process itself. apex-mcp provides two tools in this space:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/TechFernandesLTDA/apex-mcp/llms.txt
Use this file to discover all available pages before exploring further.
apex_add_item_validation to attach rules to individual page items, and apex_add_item_computation to derive or pre-populate item values at specific points in the page lifecycle.
apex_add_item_validation
Add a validation rule to a page item. Validations created by this tool run atINLINE_WITH_FIELD_AND_NOTIFICATION display location, meaning errors appear both beside the field and in the page-level notification banner.
- NOT_NULL
- REGEX
- PL/SQL Expression
- PL/SQL Function
Parameters
Page ID containing the item to validate.
The item to validate, e.g.
"P10_EMAIL". Automatically prefixed with P{page_id}_ if the prefix is missing.Display name for this validation rule, shown in the App Builder and in error messages. Use a descriptive name like
"Email Required" or "Salary Range Check".Type of validation. Accepted values and their APEX internal mapping:
| Friendly name | APEX type | Description |
|---|---|---|
not_null | ITEM_NOT_NULL | Item must not be empty. No validation_expression needed. |
max_length | MAX_LENGTH | Item value must not exceed N characters. Set N in validation_expression. |
min_length | MIN_LENGTH | Item must have at least N characters. Set N in validation_expression. |
regex | REGULAR_EXPRESSION | Item must match the regex pattern in validation_expression. |
plsql_expression | PLSQL_EXPRESSION | A PL/SQL boolean expression (referencing items via :P{n}_ITEM bind vars) that must evaluate to TRUE. |
plsql_function | PLSQL_FUNCTION_RETURNING_ERROR_TEXT | A PL/SQL function body that returns NULL when valid or an error message string when invalid. |
item_not_null_or_zero | ITEM_NOT_NULL_OR_ZERO | Item must not be null or zero. Useful for numeric required fields. |
The rule expression whose meaning depends on
validation_type:validation_type | What to put here |
|---|---|
not_null | (not used — item name is implicit) |
max_length | Maximum number of characters as a string, e.g. "100" |
min_length | Minimum number of characters as a string, e.g. "8" |
regex | Regular expression pattern, e.g. "^[0-9]+$" |
plsql_expression | Boolean PL/SQL expression, e.g. ":P10_AGE > 0 AND :P10_AGE < 120" |
plsql_function | Full PL/SQL anonymous function body returning NULL or an error string |
item_not_null_or_zero | (not used — item name is implicit) |
Message displayed to the user when the validation fails. Auto-generated from the item name and type if omitted — but providing an explicit, user-friendly message is strongly recommended.
Execution order. Validations run in ascending sequence order. Lower numbers run first.
Optional item name: only run this validation when the specified item is not null. Useful for conditional fields that are only required in certain states (e.g. only validate
P10_MANAGER_ID when P10_DEPT_TYPE = 'MANAGED').Return Value
apex_add_item_computation
Add a computation to derive or pre-populate a page item’s value at a specified point in the page lifecycle. Computations fire automatically — no user interaction is required. Common uses: pre-populate a form field from the database when the page loads, copy the current user’s name from a session variable, or derive a calculated value after submit.- Static Value
- SQL Query
- PL/SQL Expression
- Copy from Item
Parameters
Page ID.
The item whose value will be set, e.g.
"P10_FULL_NAME". Automatically prefixed with P{page_id}_ if the prefix is missing.How the value is derived. Accepted values and their APEX internal mapping:
| Friendly name | APEX type | Description |
|---|---|---|
static_value | STATIC_ASSIGNMENT | A literal fixed string |
plsql_expression | PLSQL_EXPRESSION | A PL/SQL expression evaluated at runtime (e.g. ":APP_USER") |
plsql_function | PLSQL_FUNCTION_BODY | A PL/SQL function body that returns the value |
query | QUERY | A SQL SELECT returning a single value |
item_value | ITEM_VALUE | Copy the value from another item (name in computation_expression) |
sequence | SEQUENCE | Get the next value from a DB sequence (sequence name in computation_expression) |
The value, expression, SQL, or source item name — interpreted according to
computation_type:computation_type | What to put here | ||
|---|---|---|---|
static_value | The literal string to assign, e.g. "ACTIVE" | ||
plsql_expression | PL/SQL expression, e.g. `“:APP_USER | ’@company.com’“` | |
plsql_function | Full PL/SQL function body returning the value | ||
query | Single-row SELECT statement returning one column | ||
item_value | Name of the source item, e.g. "APP_USER_ROLE" | ||
sequence | DB sequence name, e.g. "EMP_SEQ" |
When in the page lifecycle the computation runs:
| Value | When it fires |
|---|---|
BEFORE_HEADER | Before the page renders — use for initialization and pre-populating edit forms |
AFTER_SUBMIT | After the user submits the page — use for post-processing derived fields |
BEFORE_BOX_BODY | Before the page body region renders |
Execution order when multiple computations exist for the same item or page.
Optional item name: only execute this computation when the specified item is not null. This is the standard way to differentiate between “new record” (condition item is null, i.e. no PK yet) and “edit record” (condition item is not null) scenarios.
Return Value
Practical Examples
Required fields with format validation
Add NOT_NULL and email-format validations to a contact form on page 10:SQL computation to set a derived display field
Pre-populateP10_FULL_NAME from the database when opening an existing employee record:
Cross-field validation with PL/SQL expression
Ensure the end date is after the start date:Uniqueness check with PL/SQL function
Verify a username is not already in use (excluding the current record):Notes on Validation Types
not_null vs is_required on the item — Setting is_required=True on apex_add_item adds a visual required indicator (*) and applies the required field template, but does not add a server-side validation. You must call apex_add_item_validation with validation_type="not_null" separately if you want enforcement on submit.plsql_function returns the error message — Unlike plsql_expression (which must return TRUE/FALSE), the plsql_function type returns NULL to signal success and a non-null string to signal failure. The returned string becomes the error message shown to the user, so you can generate dynamic, data-driven error messages.Bind variables in PL/SQL validations — Reference page items using
:P{page_id}_ITEM_NAME syntax inside plsql_expression and plsql_function bodies. Application items are referenced as :APP_ITEM_NAME. These are Oracle bind variables resolved by APEX at execution time.