%Truncate meta-SQL element

Syntax

%Truncate(expression, factor)

Description

%Truncate truncates an expression to a specified scale before or after the decimal point.

Parameters

Parameter Description

Expression

Specify an expression involving numeric constants and database columns.

Factor

Specify an integer or bind variable in SQLExec PeopleCode. The range of a factor is -30 to +31. A negative number truncates to left of the decimal point.

Example

Here is an example:

%Truncate(10.337, 2) = 10.33

%Truncate(13.37, 0) = 13

%Truncate(19.337, -1) = 10
SQLExec("SELECT %Truncate(field_c1, :1) from RECORD_T", field_c2, &Result);

In the example, field_c1 and field_c2 are two fields in the record.

Considerations Using %Truncate

You may get incorrect results or runtime SQL errors if you try to use an expression for factor. The following code example produces incorrect results:

%Truncate(10.337, 2 + 1)