SET_SQL_CONSTRAINT

Applies to: ORAFlex SQLFlex MYSQLFlex PGFlex DB2Flex

This command allows you to put an additional constraint on your finds, moving filtering to the SQL backend. Using this command can result in significantly improved performance, since the server network traffic reduced. Note that the SQL statement passed for this command is added onto the predefined Database SQL statement so treat it as such. Because of this, it will almost always begin with “AND” followed by the desired constraint.

Syntax

SET_SQL_CONSTRAINT of {file} to {variable}
SET_SQL_CONSTRAINT of {file} FROM_PROGRAMMATIC_DEFAULTS

Parameter

Description

file

Name or Number of the file.

variable

A SQL expression that constrains the data

Examples

In this example only the customers with a status of active will be found.

Open Customer

SET_SQL_CONSTRAINT of 1 to (SFormat('AND "%1"."%2" = ' + "'%3'", "Customer", "Status", "Active"))

For_All Customer by Index.1 do
    Showln Customer.FirstName
End_For_All

In this example, all the customers will be found:

Open Customer

SET_SQL_CONSTRAINT of 1 FROM_PROGRAMMATIC_DEFAULTS

For_All Customer by Index.1 do
    Showln Customer.FirstName
End_For_All