relational-query-HDBC-0.6.8.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.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.

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