- data Statement = Statement {
- execute :: [SqlValue] -> IO Integer
- executeMany :: [[SqlValue]] -> IO ()
- finish :: IO ()
- fetchRow :: IO (Maybe [SqlValue])
- getColumnNames :: IO [String]
- originalQuery :: String
- describeResult :: IO [(String, SqlColDesc)]
- data SqlError = SqlError {
- seState :: String
- seNativeError :: Int
- seErrorMsg :: String
- class Show a => SqlType a where
- nToSql :: Integral a => a -> SqlValue
- iToSql :: Int -> SqlValue
- data SqlValue
- = SqlString String
- | SqlByteString ByteString
- | SqlWord32 Word32
- | SqlWord64 Word64
- | SqlInt32 Int32
- | SqlInt64 Int64
- | SqlInteger Integer
- | SqlChar Char
- | SqlBool Bool
- | SqlDouble Double
- | SqlRational Rational
- | SqlEpochTime Integer
- | SqlTimeDiff Integer
- | SqlNull
Documentation
Statement | |
|
The main HDBC exception object. As much information as possible is passed from the database through to the application through this object.
Errors generated in the Haskell layer will have seNativeError set to -1.
SqlError | |
|
class Show a => SqlType a whereSource
Conversions to and from SqlValue
s and standard Haskell types.
Conversions are powerful; for instance, you can call fromSql
on a SqlInt32
and get a String or a Double out of it. This class attempts to Do
The Right Thing whenever possible, and will raise an error when asked to
do something incorrect. In particular, when converting to any type
except a Maybe, SqlNull
as the input will cause an error to be raised.
Here are some notes about conversion:
- Fractions of a second are not preserved on time values
nToSql :: Integral a => a -> SqlValueSource
Converts any Integral type to a SqlValue
by using toInteger.
The main type for expressing Haskell values to SQL databases.
This type is used to marshall Haskell data to and from database APIs. HDBC driver interfaces will do their best to use the most accurate and efficient way to send a particular value to the database server.
Values read back from the server are put in the most appropriate SqlValue
type. fromSql
can then be used to convert them into whatever type
is needed locally in Haskell.
Most people will use toSql
and fromSql
instead of manipulating
SqlValue
s directly.
The default representation of time values is an integer number of seconds. Databases such as PostgreSQL with builtin timestamp types can will see automatic conversion between these Haskell types to local types. Other databases can just use an int or a string.
This behavior also exists for other types. For instance, many databases don't have a Rational type, so they'll just use Haskell's show function and store a Rational as a string.
Two SqlValues are considered to be equal if one of these hold (first one that is true holds; if none are true, they are not equal): * Both are NULL * Both represent the same type and the encapsulated values are equal * The values of each, when converted to a string, are equal.
SqlString String | |
SqlByteString ByteString | |
SqlWord32 Word32 | |
SqlWord64 Word64 | |
SqlInt32 Int32 | |
SqlInt64 Int64 | |
SqlInteger Integer | |
SqlChar Char | |
SqlBool Bool | |
SqlDouble Double | |
SqlRational Rational | |
SqlEpochTime Integer | Representation of ClockTime or CalendarTime |
SqlTimeDiff Integer | Representation of TimeDiff |
SqlNull | NULL in SQL or Nothing in Haskell |