Decimal point

You can specify a default decimal point.

The default decimal point can be specified:

  • To interpret numeric constants
  • To determine the decimal point character to use when casting a character string to a number (for example, in the DECFLOAT, DECIMAL, DOUBLE_PRECISION, FLOAT, and REAL scalar functions and the CAST specification)
  • To determine the decimal point character to use in the result when casting a number to a string (for example, in the CHAR, VARCHAR, CLOB, GRAPHIC, and VARGRAPHIC scalar functions and the CAST specification)

The default decimal point can be specified through the following interfaces:

Table 1. Default Decimal Point Interfaces
SQL Interface Specification
Embedded SQL The *JOB, *PERIOD, *COMMA, or *SYSVAL value in the OPTION parameter is specified on the Create SQL Program (CRTSQLxxx) commands. The SET OPTION statement can also be used to specify the DECMPT parameter within the source of a program containing embedded SQL. (For more information about CRTSQLxxx commands, see Embedded SQL programming.)
Interactive SQL and Run SQL Statements The DECPNT parameter on the Start SQL (STRSQL) command or by changing the session attributes. The DECMPT parameter on the Run SQL Statements (RUNSQLSTM) command. (For more information about STRSQL and RUNSQLSTM commands, see SQL programming.)
Call Level Interface (CLI) on the server SQL_ATTR_DECIMAL_SEP environment or connection variables (For more information about CLI, see SQL Call Level Interfaces (ODBC).)
JDBC or SQLJ on the server using IBM® IBM Developer Kit for Java™ Decimal Separator connection property (For more information about JDBC and SQLJ, see IBM Developer Kit for Java.)
ODBC on a client using the IBM i Access Family ODBC Driver Decimal Separator in the Advanced Server Options in ODBC Setup (For more information about ODBC, see IBM i Access.)
JDBC on a client using the IBM Toolbox for Java Format in JDBC Setup (For more information about ODBC, see IBM i Access.) (For more information about the IBM Toolbox for Java, see IBM Toolbox for Java.)

If the comma is the decimal point, the following rules apply:

  • A period will also be allowed as a decimal point.
  • A comma intended as a separator of numeric constants in a list must be followed by a space.
  • A comma intended as a decimal point must not be followed by a space.

Thus, to specify a decimal constant without a fractional part, the trailing comma must be followed by a non-blank character. The non-blank character can be a separator comma, as in:

   VALUES(9999999999,, 111)