USoft Rule Language Examples: Variable constraint messages

Previous Next

In USoft it is possible to use values from violating records in the constraint message that is presented to the end user. To make this possible, the columns from which these values are taken must be explicitly enumerated in the select-list of the constraint statement.

Unlike SQL syntax, the standard USoft Rule Language syntax is not suitable for expressing these values.

However, if the statement is USoft Rule Language then the constraint checker will attempt to resolve variables in the constraint message even though columns are not explicitly stated

If resolution is successful, the select-list items are generated into the select-list of the SQL equivalent.

If resolution of message variables in combination with a USoft Rule Language statement is NOT successful, then the constraint checker must throw a restrictive error message.

USoft Rule Language

SQL Equivalent

Message:

Message:

Customer with ID <d.id> cannot be a driver whilst having unpaid contract with code <c.code>.

Customer with ID <d.ID> cannot be a driver whilst having unpaid contract with code <c.code>.

Statement:

Statement:

 
FOR                drivers d
,                  contracts c
,                  "business parties" b
CONNECTED AS       b "PAYS FOR" c
DO NOT ALLOW THAT  b.id = d.id
AND                c.paid = 'N'

 
SELECT       d.id, c.code
FROM         driver d
,            contract c
,            business_party b
RELATE       b "PAYS FOR" c
WHERE        b.id = d.id
AND          c.paid = 'N'

 

 

See also

USoft Rule Language