SML# Document Version 4.1.0
22 SQL Expressions and Commands

22.10 SQL Library: The SQL.Numeric Structure

The SQL.Numeric structure emulates the NUMERIC type, which is the numeric type with the maximum precision in the standard SQL.

The following is its signature:

structure SQL : sig
  
  structure Numeric : sig
    type num = SQL.numeric
    val toLargeInt : num -> LargeInt.int
    val fromLargeInt : LargeInt.int -> num
    val toLargeReal : num -> LargeReal.real
    val fromLargeReal : LargeReal.real -> num
    val toInt : num -> Int.int
    val fromInt : Int.int -> num
    val toDecimal : num -> IEEEReal.decimal_approx
    val + : num * num -> num
    val - : num * num -> num
    val * : num * num -> num
    val quot : num * num -> num
    val rem : num * num -> num
    val compare : num * num -> order
    val < : num * num -> bool
    val <= : num * num -> bool
    val > : num * num -> bool
    val >= : num * num -> bool
    val ~ : num -> num
    val abs : num -> num
    val toString : num -> string
    val fromString : string -> num option
  end
end

The meaning of these functions are same as the functions of the same name defined in Int and IntInf of the Basic Library. Note that toString serializes at most 16,383 digits after the decimal point.

This SQL.Numeric structure is provided just for interaction with database systems and not intended to be a general infinite-precision decimal arithmetic library. Its performance is not considered and therefore these functions may be seriously slow.

SQL.decimal and SQL.Decimal are the aliases of SQL.numeric and SQL.Numeric, respectively.