VALIDATE

The VALIDATE instructions checks a variable value based on database schema validation rules.

Syntax

VALIDATE target [,...] LIKE
   {
      table.*
   |
      table.column
   }
  1. target is the name of the variable to be validated.
  2. If target is a record, you can use the star notation to validate all members in the record.
  3. table.column can be any column reference defined in the database schema.

Usage

The VALIDATE statement tests whether the value of the specified variable is within the range of values for a corresponding column in .val database schema file referenced by a SCHEMA clause. If the value does not match any value defined in the INCLUDE attribute of the corresponding column, the runtime system raises error -1321.

The argument of the VALIDATE instruction can be a simple variable, a record, or an array element. If the target is a record, you can use the dot-star (.*) notation to reference all record members in the validation, or specify a range of record members with the THRU clause.

Example

SCHEMA stores 
MAIN
  DEFINE cname LIKE customer.cust_name 
  LET cname = "aaa"
  VALIDATE cname LIKE customer.cust_name 
END MAIN