Skip to content

Scalar Functions

Returns the raw integer amount (in minor units):

monetary_amount(value) → BIGINT

          

Returns the currency code:

monetary_currency(value) → VARCHAR

          

Returns the amount as a decimal (with proper precision):

monetary_decimal(value) → DOUBLE

          

Creates a monetary value from components:

make_monetary(amount BIGINT, currency VARCHAR) → monetary
make_monetary(amount DOUBLE, currency VARCHAR) → monetary

          

          

Parses a string into a monetary value:

parse_monetary(text VARCHAR) → monetary

          

Returns the primary currency for a country code:

currency_for_country(country_code VARCHAR) → VARCHAR

          

Returns all countries using a currency:

countries_for_currency(currency_code VARCHAR) → VARCHAR[]

          
FunctionInputOutputDescription
monetary_amount(m)monetaryBIGINTRaw amount in minor units
monetary_currency(m)monetaryVARCHARCurrency code
monetary_decimal(m)monetaryDOUBLEDecimal amount
make_monetary(amt, cur)BIGINT/DOUBLE, VARCHARmonetaryCreate from parts
parse_monetary(text)VARCHARmonetaryParse string
currency_for_country(cc)VARCHARVARCHARCountry → currency
countries_for_currency(cc)VARCHARVARCHAR[]Currency → countries