Copyright | 2013 Kei Hibino |
---|---|
License | BSD3 |
Maintainer | ex8k.hibino@gmail.com |
Stability | experimental |
Portability | unknown |
Safe Haskell | None |
Language | Haskell2010 |
This module provides merged namespace of
typed Query
, Insert
, InsertQuery
, Update
, KeyUpdate
and Delete
running sequences.
Synopsis
- type PreparedQuery p a = PreparedStatement p a
- prepareQuery :: IConnection conn => conn -> Query p a -> IO (PreparedQuery p a)
- withPrepareQuery :: IConnection conn => conn -> Query p a -> (PreparedQuery p a -> IO b) -> IO b
- fetch :: FromSql SqlValue a => ExecutedStatement a -> IO (Maybe a)
- fetchAll :: FromSql SqlValue a => ExecutedStatement a -> IO [a]
- fetchAll' :: FromSql SqlValue a => ExecutedStatement a -> IO [a]
- fetchUnique :: FromSql SqlValue a => ExecutedStatement a -> IO (Maybe a)
- listToUnique :: [a] -> IO (Maybe a)
- fetchUnique' :: FromSql SqlValue a => ExecutedStatement a -> IO (Maybe a)
- foldlFetch :: FromSql SqlValue a => (b -> a -> IO b) -> b -> ExecutedStatement a -> IO b
- forFetch :: FromSql SqlValue a => ExecutedStatement a -> (a -> IO b) -> IO [b]
- runStatement :: FromSql SqlValue a => BoundStatement a -> IO [a]
- runStatement' :: FromSql SqlValue a => BoundStatement a -> IO [a]
- runPreparedQuery :: (ToSql SqlValue p, FromSql SqlValue a) => PreparedQuery p a -> p -> IO [a]
- runPreparedQuery' :: (ToSql SqlValue p, FromSql SqlValue a) => PreparedQuery p a -> p -> IO [a]
- runQuery :: (IConnection conn, ToSql SqlValue p, FromSql SqlValue a) => conn -> Query p a -> p -> IO [a]
- runQuery' :: (IConnection conn, ToSql SqlValue p, FromSql SqlValue a) => conn -> Query p a -> p -> IO [a]
- type PreparedInsert a = PreparedStatement a ()
- prepareInsert :: IConnection conn => conn -> Insert a -> IO (PreparedInsert a)
- runPreparedInsert :: ToSql SqlValue a => PreparedInsert a -> a -> IO Integer
- runInsert :: (IConnection conn, ToSql SqlValue a) => conn -> Insert a -> a -> IO Integer
- mapInsert :: (IConnection conn, ToSql SqlValue a) => conn -> Insert a -> [a] -> IO [Integer]
- bulkInsertInterleave :: (IConnection conn, ToSql SqlValue a) => conn -> Insert a -> [a] -> IO ([Integer], [Integer])
- bulkInsert :: (IConnection conn, ToSql SqlValue a) => conn -> Insert a -> [a] -> IO ()
- bulkInsert' :: (IConnection conn, ToSql SqlValue a) => conn -> Insert a -> [a] -> IO ([Integer], [Integer])
- chunksInsert :: (IConnection conn, ToSql SqlValue a) => conn -> Insert a -> [a] -> IO [[Integer]]
- type PreparedInsertQuery p = PreparedStatement p ()
- prepareInsertQuery :: IConnection conn => conn -> InsertQuery p -> IO (PreparedInsertQuery p)
- withPrepareInsertQuery :: IConnection conn => conn -> InsertQuery p -> (PreparedInsertQuery p -> IO a) -> IO a
- runPreparedInsertQuery :: ToSql SqlValue p => PreparedInsertQuery p -> p -> IO Integer
- runInsertQuery :: (IConnection conn, ToSql SqlValue p) => conn -> InsertQuery p -> p -> IO Integer
- type PreparedUpdate p = PreparedStatement p ()
- prepareUpdate :: IConnection conn => conn -> Update p -> IO (PreparedUpdate p)
- withPrepareUpdate :: IConnection conn => conn -> Update p -> (PreparedUpdate p -> IO a) -> IO a
- runPreparedUpdate :: ToSql SqlValue p => PreparedUpdate p -> p -> IO Integer
- runUpdate :: (IConnection conn, ToSql SqlValue p) => conn -> Update p -> p -> IO Integer
- mapUpdate :: (IConnection conn, ToSql SqlValue a) => conn -> Update a -> [a] -> IO [Integer]
- data PreparedKeyUpdate p a
- prepareKeyUpdate :: IConnection conn => conn -> KeyUpdate p a -> IO (PreparedKeyUpdate p a)
- withPrepareKeyUpdate :: IConnection conn => conn -> KeyUpdate p a -> (PreparedKeyUpdate p a -> IO b) -> IO b
- bindKeyUpdate :: ToSql SqlValue a => PreparedKeyUpdate p a -> a -> BoundStatement ()
- runPreparedKeyUpdate :: ToSql SqlValue a => PreparedKeyUpdate p a -> a -> IO Integer
- runKeyUpdate :: (IConnection conn, ToSql SqlValue a) => conn -> KeyUpdate p a -> a -> IO Integer
- type PreparedDelete p = PreparedStatement p ()
- prepareDelete :: IConnection conn => conn -> Delete p -> IO (PreparedDelete p)
- withPrepareDelete :: IConnection conn => conn -> Delete p -> (PreparedDelete p -> IO a) -> IO a
- runPreparedDelete :: ToSql SqlValue p => PreparedDelete p -> p -> IO Integer
- runDelete :: (IConnection conn, ToSql SqlValue p) => conn -> Delete p -> p -> IO Integer
- module Database.HDBC.Record.Statement
Documentation
type PreparedQuery p a = PreparedStatement p a Source #
Typed prepared query type.
:: IConnection conn | |
=> conn | Database connection |
-> Query p a | Typed query |
-> IO (PreparedQuery p a) | Result typed prepared query with parameter type |
Same as prepare
.
:: IConnection conn | |
=> conn | Database connection |
-> Query p a | Typed query |
-> (PreparedQuery p a -> IO b) | Body action to use prepared statement |
-> IO b | Result action |
Bracketed prepare operation. PreparedStatement is released on closing connection, so connection pooling cases often cause resource leaks.
fetchAll :: FromSql SqlValue a => ExecutedStatement a -> IO [a] Source #
Lazy-IO version of fetchAll'
.
fetchAll' :: FromSql SqlValue a => ExecutedStatement a -> IO [a] Source #
Strictly fetch all records.
fetchUnique :: FromSql SqlValue a => ExecutedStatement a -> IO (Maybe a) Source #
Fetch all records but get only first record. Expecting result records is unique.
listToUnique :: [a] -> IO (Maybe a) Source #
Fetch expecting result records is unique.
fetchUnique' :: FromSql SqlValue a => ExecutedStatement a -> IO (Maybe a) Source #
Fetch all records but get only first record. Expecting result records is unique. Error when records count is more than one.
:: FromSql SqlValue a | |
=> (b -> a -> IO b) | action executed after each fetch |
-> b | zero element of result |
-> ExecutedStatement a | statement to fetch from |
-> IO b |
Fetch fold-left loop convenient for the sequence of cursor-solid lock actions. Each action is executed after each fetch.
:: FromSql SqlValue a | |
=> ExecutedStatement a | statement to fetch from |
-> (a -> IO b) | action executed after each fetch |
-> IO [b] |
Fetch loop convenient for the sequence of cursor-solid lock actions. Each action is executed after each fetch.
runStatement :: FromSql SqlValue a => BoundStatement a -> IO [a] Source #
Lazy-IO version of runStatement'
.
runStatement' :: FromSql SqlValue a => BoundStatement a -> IO [a] Source #
Execute a parameter-bounded statement and strictly fetch all records.
:: (ToSql SqlValue p, FromSql SqlValue a) | |
=> PreparedQuery p a | Statement to bind to |
-> p | Parameter type |
-> IO [a] | Action to get records |
Lazy-IO version of runPreparedQuery'
.
:: (ToSql SqlValue p, FromSql SqlValue a) | |
=> PreparedQuery p a | Statement to bind to |
-> p | Parameter type |
-> IO [a] | Action to get records |
Bind parameters, execute statement and strictly fetch all records.
:: (IConnection conn, ToSql SqlValue p, FromSql SqlValue a) | |
=> conn | Database connection |
-> Query p a | Query to get record type |
-> p | Parameter type |
-> IO [a] | Action to get records |
Lazy-IO version of runQuery'
.
:: (IConnection conn, ToSql SqlValue p, FromSql SqlValue a) | |
=> conn | Database connection |
-> Query p a | Query to get record type |
-> p | Parameter type |
-> IO [a] | Action to get records |
Prepare SQL, bind parameters, execute statement and strictly fetch all records.
type PreparedInsert a = PreparedStatement a () Source #
Typed prepared insert type.
prepareInsert :: IConnection conn => conn -> Insert a -> IO (PreparedInsert a) Source #
Same as prepare
.
runPreparedInsert :: ToSql SqlValue a => PreparedInsert a -> a -> IO Integer Source #
Bind parameters, execute statement and get execution result.
runInsert :: (IConnection conn, ToSql SqlValue a) => conn -> Insert a -> a -> IO Integer Source #
Prepare insert statement, bind parameters, execute statement and get execution result.
mapInsert :: (IConnection conn, ToSql SqlValue a) => conn -> Insert a -> [a] -> IO [Integer] Source #
Prepare and insert each record.
bulkInsertInterleave :: (IConnection conn, ToSql SqlValue a) => conn -> Insert a -> [a] -> IO ([Integer], [Integer]) Source #
Prepare and insert using chunk insert statement, with the Lazy-IO results of insert statements.
bulkInsert :: (IConnection conn, ToSql SqlValue a) => conn -> Insert a -> [a] -> IO () Source #
Prepare and insert using chunk insert statement.
bulkInsert' :: (IConnection conn, ToSql SqlValue a) => conn -> Insert a -> [a] -> IO ([Integer], [Integer]) Source #
Prepare and insert using chunk insert statement, with the results of insert statements.
chunksInsert :: (IConnection conn, ToSql SqlValue a) => conn -> Insert a -> [a] -> IO [[Integer]] Source #
Deprecated: use bulkInsert' instead of this.
Deprecated. Use bulkInsert' instead of this. Prepare and insert using chunk insert statement.
type PreparedInsertQuery p = PreparedStatement p () Source #
Typed prepared insert query type.
prepareInsertQuery :: IConnection conn => conn -> InsertQuery p -> IO (PreparedInsertQuery p) Source #
Same as prepare
.
withPrepareInsertQuery :: IConnection conn => conn -> InsertQuery p -> (PreparedInsertQuery p -> IO a) -> IO a Source #
Bracketed prepare operation.
runPreparedInsertQuery :: ToSql SqlValue p => PreparedInsertQuery p -> p -> IO Integer Source #
Bind parameters, execute statement and get execution result.
runInsertQuery :: (IConnection conn, ToSql SqlValue p) => conn -> InsertQuery p -> p -> IO Integer Source #
Prepare insert statement, bind parameters, execute statement and get execution result.
type PreparedUpdate p = PreparedStatement p () Source #
Typed prepared update type.
prepareUpdate :: IConnection conn => conn -> Update p -> IO (PreparedUpdate p) Source #
Same as prepare
.
withPrepareUpdate :: IConnection conn => conn -> Update p -> (PreparedUpdate p -> IO a) -> IO a Source #
Bracketed prepare operation.
runPreparedUpdate :: ToSql SqlValue p => PreparedUpdate p -> p -> IO Integer Source #
Bind parameters, execute statement and get execution result.
runUpdate :: (IConnection conn, ToSql SqlValue p) => conn -> Update p -> p -> IO Integer Source #
Prepare update statement, bind parameters, execute statement and get execution result.
mapUpdate :: (IConnection conn, ToSql SqlValue a) => conn -> Update a -> [a] -> IO [Integer] Source #
Prepare and update with each parameter list.
data PreparedKeyUpdate p a Source #
Typed prepared key-update type.
prepareKeyUpdate :: IConnection conn => conn -> KeyUpdate p a -> IO (PreparedKeyUpdate p a) Source #
Same as prepare
.
withPrepareKeyUpdate :: IConnection conn => conn -> KeyUpdate p a -> (PreparedKeyUpdate p a -> IO b) -> IO b Source #
Bracketed prepare operation.
bindKeyUpdate :: ToSql SqlValue a => PreparedKeyUpdate p a -> a -> BoundStatement () Source #
Typed operation to bind parameters for PreparedKeyUpdate
type.
runPreparedKeyUpdate :: ToSql SqlValue a => PreparedKeyUpdate p a -> a -> IO Integer Source #
Bind parameters, execute statement and get execution result.
runKeyUpdate :: (IConnection conn, ToSql SqlValue a) => conn -> KeyUpdate p a -> a -> IO Integer Source #
Prepare insert statement, bind parameters, execute statement and get execution result.
type PreparedDelete p = PreparedStatement p () Source #
Typed prepared delete type.
prepareDelete :: IConnection conn => conn -> Delete p -> IO (PreparedDelete p) Source #
Same as prepare
.
withPrepareDelete :: IConnection conn => conn -> Delete p -> (PreparedDelete p -> IO a) -> IO a Source #
Bracketed prepare operation.
runPreparedDelete :: ToSql SqlValue p => PreparedDelete p -> p -> IO Integer Source #
Bind parameters, execute statement and get execution result.