hmssql
Safe HaskellNone
LanguageHaskell2010

Hmssql.SqlValue

Description

A value of any SQL Server type, for code that handles columns and parameters whose types are only known at runtime: serving any table, copying rows between tables, a REPL.

Decoding: SqlValue is a FromSqlField that accepts any column (sqlValueDecoder), and SqlRow a whole row with its columns (sqlRowDecoder, sqlRowDecoderFor); queryMulti and callProcedure return every result set as SqlRows. A sql_variant decodes as its base type.

Encoding: SqlValue is a ToSqlField sent as the type its constructor names, so SELECT @p1 gives the same value back; SqlNull is an nvarchar(max) NULL, which the server converts to most types but not to binary or sql_variant.

Synopsis

Documentation

data SqlValue Source #

One constructor per family of SQL Server types.

Constructors

SqlNull 
SqlBool !Bool
bit
SqlWord8 !Word8

tinyint: an unsigned value from 0 through 255

SqlInt16 !Int16
smallint
SqlInt32 !Int32
int
SqlInt64 !Int64
bigint
SqlFloat !Float
real
SqlDouble !Double
float
SqlDecimal !Decimal

decimal, numeric

SqlMoney !Money

money, smallmoney

SqlGuid !UUID
uniqueidentifier
SqlDateTime !LocalTime

datetime, smalldatetime, datetime2

SqlDate !Day
date
SqlTime !TimeOfDay
time
SqlDateTimeOffset !DateTimeOffset
datetimeoffset
SqlText !Text

The character types: char, varchar, text (decoded by the collation's code page), nchar, nvarchar, ntext, and json and vector, which arrive as character types

SqlBinary !ByteString

binary, varbinary, image, rowversion

SqlXml !Text
xml

Instances

Instances details
Show SqlValue Source # 
Instance details

Defined in Hmssql.SqlValue

Eq SqlValue Source # 
Instance details

Defined in Hmssql.SqlValue

FromSqlField SqlValue Source # 
Instance details

Defined in Hmssql.Decoding

ToSqlField SqlValue Source #

Each constructor is sent as the wire type FromSqlField SqlValue decodes it from, so SELECT @p1 returns the same SqlValue: SqlXml as xml (UTF-16 with a byte order mark, no schema collection), SqlText as nvarchar, and so on. SqlNull is an nvarchar(max) NULL, which the server won't convert to sql_variant (error 206).

Instance details

Defined in Hmssql.Encoding

Methods

fieldEncoder :: FieldEncoder SqlValue Source #

fieldParam :: SqlValue -> FieldParams -> FieldParams

data SqlRow Source #

A row of SqlValues with the columns they came from.

Constructors

SqlRow 

Fields

Instances

Instances details
Show SqlRow Source # 
Instance details

Defined in Hmssql.SqlValue

Eq SqlRow Source # 
Instance details

Defined in Hmssql.SqlValue

Methods

(==) :: SqlRow -> SqlRow -> Bool #

(/=) :: SqlRow -> SqlRow -> Bool #