Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » UltraLite - Database Management and Developer Guide » UltraLite database reference » UltraLite options

UltraLite scale creation option

Specifies the minimum number of digits after the decimal point when an arithmetic result is truncated to the maximum precision.

Syntax
scale=value
Allowed values

Integer, between 0 and 127, inclusive

Default

6

Remarks

For Android devices, you can use Connection.setOption(OPTION_SCALE, value) as an alternative to setting this creation option.

The position of the decimal point is determined by the precision and the scale of the number: precision is the total number of digits to the left and right of the decimal point; scale is the minimum number of digits after the decimal point when an arithmetic result is truncated to the maximum precision.

Choosing an appropriate decimal point position is typically determined by:

  • The type of arithmetic procedures you perform

    Multiplication, division, addition, subtraction, and aggregate functions can all have results that exceed the maximum precision.

    For example, when a DECIMAL(8,2) is multiplied with a DECIMAL(9,2), the result could require a DECIMAL(17,4). If precision is 15, only 15 digits are kept in the result. If scale is 4, the result is a DECIMAL(15,4). If scale is 2, the result is a DECIMAL(15,2). In both cases, there is a possibility of an overflow error.

  • The relationship between scale and precision values

    The scale sets the number of digits in the fractional part of the number, and cannot be negative or greater than the precision.

You cannot change the scale of an existing database. Instead, you must create a new database.

From SQL Central, you can set the scale in any wizard that creates a database. On the New database creation parameters page, click the Scale option.

From a client application, set this option as one of the creation options for the CreateDatabase method on the DatabaseManager/ULDatabaseManager class.

Example

When a DECIMAL(8,2) is multiplied with a DECIMAL(9,2), the result could require a DECIMAL(17,4). If precision is 15, only 15 digits are kept in the result. If scale is 4, the result is DECIMAL(15,4). If scale is 2, the result is a DECIMAL(15,2). In both cases, there is a possibility of overflow.