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

Typed prepared query type.

prepareQuery Source #

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

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

Fetch a record.

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.

foldlFetch Source #

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

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

runPreparedQuery Source #

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' Source #

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

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' Source #

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

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.

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

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