Scalar Functions
Accessor Functions
Section titled “Accessor Functions”monetary_amount
Section titled “monetary_amount”Returns the raw integer amount (in minor units):
monetary_amount(value) → BIGINTmonetary_currency
Section titled “monetary_currency”Returns the currency code:
monetary_currency(value) → VARCHARmonetary_decimal
Section titled “monetary_decimal”Returns the amount as a decimal (with proper precision):
monetary_decimal(value) → DOUBLEConstructor Functions
Section titled “Constructor Functions”make_monetary
Section titled “make_monetary”Creates a monetary value from components:
make_monetary(amount BIGINT, currency VARCHAR) → monetarymake_monetary(amount DOUBLE, currency VARCHAR) → monetaryparse_monetary
Section titled “parse_monetary”Parses a string into a monetary value:
parse_monetary(text VARCHAR) → monetaryCountry/Currency Functions
Section titled “Country/Currency Functions”currency_for_country
Section titled “currency_for_country”Returns the primary currency for a country code:
currency_for_country(country_code VARCHAR) → VARCHARcountries_for_currency
Section titled “countries_for_currency”Returns all countries using a currency:
countries_for_currency(currency_code VARCHAR) → VARCHAR[]Summary
Section titled “Summary”| Function | Input | Output | Description |
|---|---|---|---|
monetary_amount(m) | monetary | BIGINT | Raw amount in minor units |
monetary_currency(m) | monetary | VARCHAR | Currency code |
monetary_decimal(m) | monetary | DOUBLE | Decimal amount |
make_monetary(amt, cur) | BIGINT/DOUBLE, VARCHAR | monetary | Create from parts |
parse_monetary(text) | VARCHAR | monetary | Parse string |
currency_for_country(cc) | VARCHAR | VARCHAR | Country → currency |
countries_for_currency(cc) | VARCHAR | VARCHAR[] | Currency → countries |