FORMULA()

Previous Next

Subjects values in a non-SQL environment to operations requiring a SQL evaluator.

Use FORMULA() outside SQL, i.e. in method call syntax, to:

· Subject values to scalar SQL functions such as ROUND(), SUBSTR() and so on.

 

· Subject numerical values to mathematical operations.

 

· Concatenate string values.

You can use any SQL syntax supported by your database vendor. To keep your USoft application portable between databases, however, you should adhere to standards. This is particularly a concern when calling SQL functions. USoft converts certain key SQL functions automatically between databases. Others are database-specific. Please consult the Definer Help for details.

FORMULA is itself an embedded method call that returns a string value to the embedding method call. For more information, see the FORMULA()help topic

Syntax

FORMULA(<formula>, <value>, [, <value>...])

Parameters

formula

SQL expression, with placeholders representing the values identified by the other parameters: :1 represents value 1, :2 represents value 2, and so on.

value

Values used in the SQL expression. These can be hard-coded strings, or values represented by embedded method calls.

Examples

FORMULA(':1 || :2',query.file_name(),'.TXT')

FORMULA(':1 || SUBSTR(INSTR(:2,:3)',

  'Domain = ', query.email(), '@')