substr()

The substr() function extracts a substring from a value specified by the parameter.

Example of the lng Function Translation
Service Manager function Translated SQL equivalent:
select ps.number, ps.title from probsummary ps where substr(ps.openen.by, 0, 3)=”fal”
select t01.”NUMBER”, t01.”TITLE” from PROBSUMMARYM1 t01 where SUBSTR(t01.”OPENED_BY”) = ‘fal’

The first parameter can only be a field name or an expression that can be evaluated beforehand, it cannot be an expression that cannot be evaluated before translation into SQL. The other parameters can only be constant numbers or expressions that can be evaluated to numbers before translation into SQL:

The following cases are valid:

substr ( ps.category, 0, 4 )   //In this example, “category” is a field from file “probsummary”
substr ( $L.var, 0, 4 )   //In this example,$L.var is a local variable defined beforehand.
The following cases are invalid:
substr ( ps.title + ps.brief, 0, 4 )
substr ( ps.title + $L.var, 0, 4 )