relational-query-HDBC-0.7.1.0: 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.Query

Contents

Description

This module provides typed Query running sequence which intermediate structures are typed.

Synopsis

Prepare

type PreparedQuery p a = PreparedStatement p a Source #

Typed prepared query type.

prepare 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

Typed prepare query operation.

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 strictly

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

Fetch a record.

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

Strictly fetch all records.

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.

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.

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

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

Prepare SQL, bind parameters, execute statement and strictly fetch all records.

Fetch loop

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.

Fetch with Lazy-IO

CAUTION!!

Lazy-IO APIs may be harmful in complex transaction with RDBMs interfaces which require sequential ordered calls of low-level APIs.

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

Lazy-IO version of fetchAll'.

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

Lazy-IO version of runStatement'.

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

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