VALIDATE statement
- Last Updated: January 18, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Verifies that a record complies with mandatory field and unique index definitions.
Syntax
|
- record
-
The name of the record you want to validate.
To validate a record in a table defined for multiple databases, you must qualify the record's table name with the database name. See the record definition in the Record phrase reference entry for more information.
- NO-ERROR
- The NO-ERROR option is used to
prevent the statement from raising
ERRORand displaying error messages.
Example
This procedure prompts for an item number. If an Item with that number is
not available, the procedure creates a new Item record and lets you supply some Item
information. The VALIDATE statement checks the data you enter against the
index and mandatory field criteria for the Item record.
r-valid.p
|
Notes
- Because validation is done automatically, you rarely have to use the
VALIDATEstatement. The AVM automatically validates a record when a record in the record buffer is replaced by another, a record's scope iterates or ends, the innermost iterating subtransaction block that creates a record iterates, or a transaction ends.
- The AVM automatically validates mandatory fields when those fields are modified.
- If the validation fails on a newly-created record,
VALIDATEraises theERRORcondition. - The AVM performs validation when it leaves a field.
- For complex validations, it might be easier to use the
IF...THEN...ELSEstatement instead of theVALIDATEstatement. - You cannot use the
VALIDATEstatement to test fields that are referenced in SQL statements, since validation is not performed for these fields. - If a field or table has been modified, the
VALIDATEstatement causesWRITEevents and all relatedWRITEtriggers to execute.