MetaHDBC-0.1.0: Statically checked database accessContentsIndex
Database.MetaHDBC.SqlExpr
Contents
Helper functions to construct directly runned statements (runStmt)
Helper function to construct prepared statements
Synopsis
runStmt :: String -> String -> ExpQ
prepareStmt :: String -> String -> ExpQ
strict :: IO [a] -> IO [a]
data ExprParts = ExprParts {
parameters :: [Parameter]
returnTypes :: [SqlColDesc]
dbSqlExpr :: String
connectionName :: Name
}
data Parameter = Parameter {
parmName :: Name
typeID :: SqlColDesc
isBound :: Bool
}
data PrepareParts = PrepareParts {
exprParts :: ExprParts
stmtName :: Name
}
rethrowDoing :: IO a -> String -> IO a
sqlInfo :: String -> String -> IO String
makeExprParts :: String -> String -> Q ExprParts
runStmtLHS :: ExprParts -> ExpQ -> ExpQ
runStmtRHS :: ExprParts -> ExpQ
makePrepStmtParts :: String -> String -> Q PrepareParts
prepStmtLHS :: PrepareParts -> [StmtQ] -> ExpQ
prepStmtQ :: PrepareParts -> StmtQ
execPrepStmtRHS :: PrepareParts -> StmtQ
returnExecPrepStmtLHS :: PrepareParts -> [StmtQ] -> StmtQ
Documentation
runStmt
:: StringData source name (DSN)
-> StringSQL statement extended with question marks for parameteres
-> ExpQ

The expression has type Connection -> a1 -> ... -> an -> IO [x1, ... xm]), where a1-an are inputs to the statement (due to placeholder arguments), and x1-xm are the outputs from the statement.

If there are no outputs from the statement (e.g. an insert statement) the number of affected rows is returned.

Statically typed one-off (not prepared) SQL statement.
prepareStmt
:: StringData source name (DSN)
-> StringSQL statement extended with question marks for parameteres
-> ExpQ

The expression has type Connection -> IO (a1 -> ... -> an -> IO [x1, ... xm]), where a1-an are inputs to the statement (due to placeholder arguments), and x1-xm are the outputs from the statement.

If there are no outputs from the statement (e.g. an insert statement) the number of affected rows is returned.

Statically typed prepared SQL statement.
strict :: IO [a] -> IO [a]
Makes the query result from prepareStmt or runStmt strict.
data ExprParts
Common parts for both statements run directly (runStmt) and prepared statements.
Constructors
ExprParts
parameters :: [Parameter]Positional parameters
returnTypes :: [SqlColDesc]Description of values returned from a SQL statement
dbSqlExpr :: StringThe SQL expression which is passed on to the database
connectionName :: NameName of the Connection parameter.
data Parameter
Describing a positional parameter
Constructors
Parameter
parmName :: Name
typeID :: SqlColDesc
isBound :: Bool
data PrepareParts
Parts used in prepared statements
Constructors
PrepareParts
exprParts :: ExprParts
stmtName :: Name
rethrowDoing :: IO a -> String -> IO a
sqlInfo :: String -> String -> IO String
Returns textual information about a query. The returned String is useful as presentation to a user, not for further processing.
makeExprParts :: String -> String -> Q ExprParts
Contructs expression-parts. A database is contacting to parse the SQL and infer correct types.
Helper functions to construct directly runned statements (runStmt)
runStmtLHS
:: ExprParts
-> ExpQExpression which is expected to access the database
-> ExpQ
Constructs a lambda which given a connection and parameters will execute expr. See runStmtRHS.
runStmtRHS :: ExprParts -> ExpQ
Creates an exprresion which runs a SQL statement on a database server. It is expected that the connection variable and parameters has already been bound. See also runStmtLHS.
Helper function to construct prepared statements
makePrepStmtParts :: String -> String -> Q PrepareParts
Creates parts for a prepared statement. Calls makeExprParts.
prepStmtLHS :: PrepareParts -> [StmtQ] -> ExpQ
Lambda for prepared statements.
prepStmtQ :: PrepareParts -> StmtQ
A StmtQ which prepares a statement on a database.
execPrepStmtRHS :: PrepareParts -> StmtQ
A StmtQ to execute a statement on a database.
returnExecPrepStmtLHS :: PrepareParts -> [StmtQ] -> StmtQ
Creates a StmtQ of type: IO (a1-an -> IO ... ). Where a1-an are the parameters which must be bound.
Produced by Haddock version 2.1.0