relational-query-HDBC-0.7.1.1: HDBC instance of relational-query and typed query interface for HDBC

Copyright2013 Kei Hibino
LicenseBSD3
Maintainerex8k.hibino@gmail.com
Stabilityexperimental
Portabilityunknown
Safe HaskellNone
LanguageHaskell2010

Database.HDBC.Record

Description

This module provides merged namespace of typed Query, Insert, InsertQuery, Update, KeyUpdate and Delete running sequences.

Synopsis

Documentation

type PreparedQuery p a = PreparedStatement p a #

Typed prepared query type.

prepareQuery #

Arguments

:: IConnection conn 
=> conn

Database connection

-> Query p a

Typed query

-> IO (PreparedQuery p a)

Result typed prepared query with parameter type p and result type a

Same as prepare.

withPrepareQuery #

Arguments

:: 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.

fetch :: FromSql SqlValue a => ExecutedStatement a -> IO (Maybe a) #

Fetch a record.

fetchAll :: FromSql SqlValue a => ExecutedStatement a -> IO [a] #

Lazy-IO version of fetchAll'.

fetchAll' :: FromSql SqlValue a => ExecutedStatement a -> IO [a] #

Strictly fetch all records.

fetchUnique :: FromSql SqlValue a => ExecutedStatement a -> IO (Maybe a) #

Fetch all records but get only first record. Expecting result records is unique.

listToUnique :: [a] -> IO (Maybe a) #

Fetch expecting result records is unique.

fetchUnique' :: FromSql SqlValue a => ExecutedStatement a -> IO (Maybe a) #

Fetch all records but get only first record. Expecting result records is unique. Error when records count is more than one.

foldlFetch #

Arguments

:: 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.

forFetch #

Arguments

:: 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] #

Lazy-IO version of runStatement'.

runStatement' :: FromSql SqlValue a => BoundStatement a -> IO [a] #

Execute a parameter-bounded statement and strictly fetch all records.

runPreparedQuery #

Arguments

:: (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'.

runPreparedQuery' #

Arguments

:: (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.

runQuery #

Arguments

:: (IConnection conn, ToSql SqlValue p, FromSql SqlValue a) 
=> conn

Database connection

-> Query p a

Query to get record type a requires parameter p

-> p

Parameter type

-> IO [a]

Action to get records

Lazy-IO version of runQuery'.

runQuery' #

Arguments

:: (IConnection conn, ToSql SqlValue p, FromSql SqlValue a) 
=> conn

Database connection

-> Query p a

Query to get record type a requires parameter p

-> 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 () #

Typed prepared insert type.

prepareInsert :: IConnection conn => conn -> Insert a -> IO (PreparedInsert a) #

Same as prepare.

runPreparedInsert :: ToSql SqlValue a => PreparedInsert a -> a -> IO Integer #

Bind parameters, execute statement and get execution result.

runInsert :: (IConnection conn, ToSql SqlValue a) => conn -> Insert a -> a -> IO Integer #

Prepare insert statement, bind parameters, execute statement and get execution result.

mapInsert :: (IConnection conn, ToSql SqlValue a) => conn -> Insert a -> [a] -> IO [Integer] #

Prepare and insert each record.

bulkInsertInterleave :: (IConnection conn, ToSql SqlValue a) => conn -> Insert a -> [a] -> IO ([Integer], [Integer]) #

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 () #

Prepare and insert using chunk insert statement.

bulkInsert' :: (IConnection conn, ToSql SqlValue a) => conn -> Insert a -> [a] -> IO ([Integer], [Integer]) #

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]] #

Deprecated: use bulkInsert' instead of this.

Deprecated. Use bulkInsert' instead of this. Prepare and insert using chunk insert statement.

type PreparedInsertQuery p = PreparedStatement p () #

Typed prepared insert query type.

withPrepareInsertQuery :: IConnection conn => conn -> InsertQuery p -> (PreparedInsertQuery p -> IO a) -> IO a #

Bracketed prepare operation.

runPreparedInsertQuery :: ToSql SqlValue p => PreparedInsertQuery p -> p -> IO Integer #

Bind parameters, execute statement and get execution result.

runInsertQuery :: (IConnection conn, ToSql SqlValue p) => conn -> InsertQuery p -> p -> IO Integer #

Prepare insert statement, bind parameters, execute statement and get execution result.

type PreparedUpdate p = PreparedStatement p () #

Typed prepared update type.

prepareUpdate :: IConnection conn => conn -> Update p -> IO (PreparedUpdate p) #

Same as prepare.

withPrepareUpdate :: IConnection conn => conn -> Update p -> (PreparedUpdate p -> IO a) -> IO a #

Bracketed prepare operation.

runPreparedUpdate :: ToSql SqlValue p => PreparedUpdate p -> p -> IO Integer #

Bind parameters, execute statement and get execution result.

runUpdate :: (IConnection conn, ToSql SqlValue p) => conn -> Update p -> p -> IO Integer #

Prepare update statement, bind parameters, execute statement and get execution result.

mapUpdate :: (IConnection conn, ToSql SqlValue a) => conn -> Update a -> [a] -> IO [Integer] #

Prepare and update with each parameter list.

data PreparedKeyUpdate p a #

Typed prepared key-update type.

prepareKeyUpdate :: IConnection conn => conn -> KeyUpdate p a -> IO (PreparedKeyUpdate p a) #

Same as prepare.

withPrepareKeyUpdate :: IConnection conn => conn -> KeyUpdate p a -> (PreparedKeyUpdate p a -> IO b) -> IO b #

Bracketed prepare operation.

bindKeyUpdate :: ToSql SqlValue a => PreparedKeyUpdate p a -> a -> BoundStatement () #

Typed operation to bind parameters for PreparedKeyUpdate type.

runPreparedKeyUpdate :: ToSql SqlValue a => PreparedKeyUpdate p a -> a -> IO Integer #

Bind parameters, execute statement and get execution result.

runKeyUpdate :: (IConnection conn, ToSql SqlValue a) => conn -> KeyUpdate p a -> a -> IO Integer #

Prepare insert statement, bind parameters, execute statement and get execution result.

type PreparedDelete p = PreparedStatement p () #

Typed prepared delete type.

prepareDelete :: IConnection conn => conn -> Delete p -> IO (PreparedDelete p) #

Same as prepare.

withPrepareDelete :: IConnection conn => conn -> Delete p -> (PreparedDelete p -> IO a) -> IO a #

Bracketed prepare operation.

runPreparedDelete :: ToSql SqlValue p => PreparedDelete p -> p -> IO Integer #

Bind parameters, execute statement and get execution result.

runDelete :: (IConnection conn, ToSql SqlValue p) => conn -> Delete p -> p -> IO Integer #

Prepare delete statement, bind parameters, execute statement and get execution result.