%Round meta-SQL element
Syntax
%Round(expression, factor)
Description
%Round rounds an expression to a specified scale before or after the decimal point. If factor is a literal, it can be rounded to a negative number.
Parameters
| Parameter | Description |
|---|---|
|
expression |
Specify an arbitrary numeric expression involving numeric constants and database columns. |
|
factor |
Specify an integer or bind variable in SQLExec PeopleCode. The range of a factor is from -31 to +31 for literals. Non-literals can only be positive. |
Example
Here is an example:
%Round(10.337, 2) = 10.34
%Round(13.67, 0) = 14
SQLExec("SELECT %Round(field_c1, :1) from RECORD_T", field_c2, &Result);
In the example, field_c1 and field_c2 are two fields in the record.
The following cases are illegal, and may cause incorrect results or runtime SQL errors:
%Round(10.337, 2 + 1) (factor can not be an expression)
%Round(field_c1, field_c2) (factor can not be database columns)