DBFORMAT
Defines currency symbol, decimal and thousands separator for input and display of numeric values.
The DBFORMAT environment variable defines the input and display format for numeric values.
- When defined, the DBFORMAT environment variable takes precedence over DBMONEY.
- The DBFORMAT environment variable is also used by the IBM® Informix® database client and server to make date to string conversions.
-
When using a graphical front-end, the decimal separator of the numeric keypad will produce the character defined by the DBFORMAT (or DBMONEY) environment variables.
The value of a DBFORMAT variable must use the following syntax:
front:thousands:decimal:back
- front is the leading currency symbol, can be an asterisk ( * ).
- thousands is a character that you specify as a valid thousands separator, can be an asterisk ( * ).
- decimal is a character that you specify as a valid decimal separator.
- back is the trailing currency symbol, can be an asterisk ( * ).
DBFORMAT takes precedence over DBMONEY.
- On desktop/server platforms, the default numeric format defines the (
,
) comma as thousands separator, the (.
) dot as decimal separator, and the ($
) dollar sign as front currency symbol for MONEY values. This corresponds toDBMONEY="$."
, orDBFORMAT="$:,:.:"
. - On mobile platforms, the numeric format defaults to the regional settings defined on the device. Normally, there is no need to modify these defaults.
DBFORMAT can be set to define the input and display format for values of these types:
MONEY
(thousands separator, decimal separator and currency symbol)DECIMAL
(thousands separator, decimal separator)SMALLFLOAT
(thousands separator, decimal separator)FLOAT
(thousands separator, decimal separator)SMALLINT
(thousands separator)INTEGER
(thousands separator)BIGINT
(thousands separator)
DBFORMAT can specify the leading and trailing currency symbols (but not their default positions within a monetary value) and the decimal and thousands separators. The decimal and thousands separators defined by DBFORMAT apply to both monetary and other numeric data.
The instructions affected by the setting in DBFORMAT include (but are not restricted to) these items:
USING
operator.FORMAT
field attribute.DISPLAY
orPRINT
statement (default formatting of numeric values).LET
statement, where aCHAR
,VARCHAR
orSTRING
variable is assigned a monetary or number value.LOAD
andUNLOAD
statements that use ASCII files (or whatever the locale regards as a flat file) to pass data to or from the database.
The asterisk ( * ) specifies that a symbol or separator is not applicable; it is the default for any front, thousands, or back term that you do not define.
If you specify more than one character for decimal or thousands, the values in the decimal or thousands list cannot be separated by spaces (nor by any other symbols). However, only the first character will be used to display numeric or currency values, when converting strings to numbers and when entering values in form fields.
Any printable character that your locale supports is valid for the thousands separator or for
the decimal separator, except 0-9
digits, <
,
>,
, |
, ?
, !
,
=
, [
and ]
.
The same character cannot be both the thousands and decimal separator. A blank space (ASCII 32) can be the thousands separator (and is conventionally used for this purpose in some locales). The asterisk ( * ) symbol is valid as the decimal separator, but is not valid as the thousands separator.
Enclosing the DBFORMAT specification in a pair of single quotation marks is recommended to prevent the shell from attempting to interpret (or execute) any of the DBFORMAT characters.
The setting in DBFORMAT affects how formatting masks of the FORMAT
attribute and
USING
operator are interpreted. In formatting masks of FORMAT
and
USING
, these symbols are not literal characters but are placeholders for what
DBFORMAT specifies:
- The dollar ($) sign is a placeholder for the front currency symbol.
- The comma (,) is a placeholder for the thousands separator.
- The period (.) is a placeholder for the decimal separator.
- The at (@) sign is a placeholder for the back currency symbol.
This table illustrates the results of different combinations of DBFORMAT setting and format string on the same value.
Value | Format String | DBFORMAT | Result |
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
When the user enters numeric or currency values in fields, the runtime system behaves as follows:
- If a symbol is entered that was defined as a decimal separator in DBFORMAT, it is interpreted as the decimal separator.
- For
MONEY
fields, it disregards any front (leading) or back (trailing) currency symbol and any thousands separators that the user enters. - For
DECIMAL
fields, the user must enter values without currency symbols.
When the runtime system displays or prints values:
- The DBFORMAT-defined leading or trailing currency symbol is displayed for
MONEY
values. - If a leading or trailing currency symbol is specified by the
FORMAT
attribute for non-MONEY data types, the symbol is displayed. - The thousands separator is not displayed unless it is included in a formatting mask of the
FORMAT
attribute or of the USING operator.
When MONEY
values are converted to character strings by the
LET
statement, both automatic data type conversion and explicit conversion
with a USING
clause insert the DBFORMAT-defined separators and currency
symbol into the converted strings.
*:.:,:SFr
1234,56SFr
Here SFr
stands for the Swiss Franc currency symbol. Values input by the
user into a screen form are expected to contain commas, not periods, as their decimal
separator because DBFORMAT has
as its setting in
this example.*:.:,:SFr