CURRENCY

The CURRENCY function returns a value that is formatted as an amount with a user-specified currency symbol and, if specified, one of three symbols that indicate debit or credit.

Read syntax diagramSkip visual syntax diagramCURRENCY(input-amount, currency-symbol, credit/debit-indicator)

The schema is DSN8.

input-amount
An expression that specifies the value to be formatted. The expression must be a floating-point value.
currency-symbol
A character string that specifies the currency symbol. The string must have a data type of VARCHAR and an actual length that is not greater than 2 bytes.
credit/debit-indicator
A character string that specifies the symbol that is included with the result to indicate whether the value is negative or positive. The string must have a data type of VARCHAR and an actual length that is not greater than 5 bytes. If credit/debit-indicator is not specified or is the value null, the result is formatted without an indicator symbol. You can specify the following symbols:
CR/DB
Bank style. Negative input values are appended with 'DB'; positive input values are appended with 'CR'.
+/-
Arithmetic style. Negative input values are prefixed with a minus sign '-'; positive values are formatted without symbols.
(/)
Accounting style. Negative input values are enclosed in parentheses '( )'; positive values are formatted without symbols.

The result of the function is VARCHAR(19).

The CURRENCY function uses the C language functions strfmon to facilitate formatting of money amounts and setlocale to initialize strfmon for local conventions. If setlocale fails, the CURRENCY function returns an error.

The following table shows the external program and specific names for CURRENCY. The specific names differ depending on the input to the function.
Table 1. External program and specific names for CURRENCY
Input arguments External name Specific name
input-amount
currency-symbol
DSN8DUCY DSN8.DSN8DUCYFV
input-amount
currency-symbol
credit/debit-indicator
DSN8DUCY DSN8.DSN8DUCYFVV
Example 1: Express® '-1234.56' as an amount in US dollars, using the bank style debit/credit indicator to indicate whether the value is negative or positive.
   VALUES DSN8.CURRENCY( -1234.56,'$','CR/DB' );
The result of the function is '$1,234.56 DB'.
Example 2: Express '-1234.56' as an amount in Deutsche marks, using the accounting style debit/credit indicator to indicate whether the value is negative or positive.
   VALUES DSN8.CURRENCY( -1234.56,'DM','(/)' );
The result of the function is '(DM 1,234.56)'.
Example 3: Express '-1234.56' as an amount in Canadian dollars, using the accounting style debit/credit indicator to indicate whether the value is negative or positive.
   VALUES DSN8.CURRENCY( -1234.56,'CD','+/-' );
The result of the function is '-CD 1,234.56'.