Invocative Constraints

Previous Next

See Also

An invocative constraint calls a method of a component from an INVOKE statement. The component takes care of validating the data entered by the user, or performs subsequent actions. You can use invocative constraints to:

· Validate data that cannot be validated by the Rules Engine.

For example, you can check if an email address string exists in the address book of your email program. More general, you can check if certain data exists in an external data source. You can also check if entered data matches an advanced IO format that cannot be defined in SQL syntax, like area codes or bank account numbers.

This way, an invocative constraint may result in a violation, and can be compared with a restrictive constraint.

· Call an internal component that issues a warning message instead of an error message. This way, you can define warning constraints.

 

· Let an external component perform an action, for example send an e-mail message, update external data, or play a tune whenever data is manipulated.

An invocative constraint has syntax:

INVOKE    <component>.{<method|query protocol>}

WITH

SELECT    <select-list>

FROM    <table> [,<table2>]

WHERE    <condition(s)>

An invocative constraint is evaluated as a result of the user manipulating a specific record. The component is invoked only for this record, at the time the record is stored (if at all).

The method that is invoked can have return parameters. If this method has NO return or output parameters, the constraint never results in a violation. All functionality is determined by the component code.

If the method returns a value, you must associate the method with the Query Protocol, and then INVOKE the query protocol instead of the method. The Rules Engine then interprets the component's return value as follows:

Value

Interpreted As

-1

Error

0

No record returned à No violation.

1

Record returned à Violation.

 

NOTE:

If the SQL statement of a constraint does not start with the INVOKE keyword, the constraint is NOT categorized as invocative, but as a restrictive or corrective constraint.

For more information about components and the INVOKE keyword, refer to: "Rules-Driven Method Invocation (RDMI)".