Copyright | 2013-2018 Kei Hibino |
---|---|
License | BSD3 |
Maintainer | ex8k.hibino@gmail.com |
Stability | experimental |
Portability | unknown |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This module provides typed statement running sequence which intermediate structures are typed.
Synopsis
- data PreparedStatement p a
- untypePrepared :: PreparedStatement p a -> Statement
- unsafePrepare :: IConnection conn => conn -> String -> IO (PreparedStatement p a)
- finish :: PreparedStatement p a -> IO ()
- withUnsafePrepare :: IConnection conn => conn -> String -> (PreparedStatement p a -> IO b) -> IO b
- withPrepareNoFetch :: (UntypeableNoFetch s, IConnection conn) => conn -> s p -> (PreparedStatement p () -> IO a) -> IO a
- data BoundStatement a = BoundStatement {}
- bind :: ToSql SqlValue p => PreparedStatement p a -> p -> BoundStatement a
- bindTo :: ToSql SqlValue p => p -> PreparedStatement p a -> BoundStatement a
- data ExecutedStatement a
- executed :: ExecutedStatement a -> Statement
- result :: ExecutedStatement a -> Integer
- executeBound :: BoundStatement a -> IO (ExecutedStatement a)
- execute :: ToSql SqlValue p => PreparedStatement p a -> p -> IO (ExecutedStatement a)
- prepareNoFetch :: (UntypeableNoFetch s, IConnection conn) => conn -> s p -> IO (PreparedStatement p ())
- executeBoundNoFetch :: BoundStatement () -> IO Integer
- executeNoFetch :: ToSql SqlValue a => PreparedStatement a () -> a -> IO Integer
- runNoFetch :: (UntypeableNoFetch s, IConnection conn, ToSql SqlValue a) => conn -> s a -> a -> IO Integer
- mapNoFetch :: (UntypeableNoFetch s, IConnection conn, ToSql SqlValue a) => conn -> s a -> [a] -> IO [Integer]
- executePrepared :: ToSql SqlValue p => PreparedStatement p a -> p -> IO (ExecutedStatement a)
- runPreparedNoFetch :: ToSql SqlValue a => PreparedStatement a () -> a -> IO Integer
Documentation
data PreparedStatement p a Source #
Typed prepared statement type.
untypePrepared :: PreparedStatement p a -> Statement Source #
Unsafely untype prepared statement.
:: IConnection conn | |
=> conn | Database connection |
-> String | Raw SQL String |
-> IO (PreparedStatement p a) | Result typed prepared query with parameter type |
Run prepare and unsafely make Typed prepared statement.
finish :: PreparedStatement p a -> IO () Source #
Close PreparedStatement. Useful for connection pooling cases. PreparedStatement is released on closing connection, so connection pooling cases often cause resource leaks.
:: IConnection conn | |
=> conn | Database connection |
-> String | Raw SQL String |
-> (PreparedStatement p a -> IO b) | |
-> IO b |
Bracketed prepare operation. Unsafely make Typed prepared statement. PreparedStatement is released on closing connection, so connection pooling cases often cause resource leaks.
withPrepareNoFetch :: (UntypeableNoFetch s, IConnection conn) => conn -> s p -> (PreparedStatement p () -> IO a) -> IO a Source #
Bracketed prepare operation.
Generalized prepare inferred from UntypeableNoFetch
instance.
data BoundStatement a Source #
Typed prepared statement which has bound placeholder parameters.
:: ToSql SqlValue p | |
=> PreparedStatement p a | Prepared query to bind to |
-> p | Parameter to bind |
-> BoundStatement a | Result parameter bound statement |
Typed operation to bind parameters. Inferred ToSql
is used.
bindTo :: ToSql SqlValue p => p -> PreparedStatement p a -> BoundStatement a Source #
Same as bind
except for argument is flipped.
data ExecutedStatement a Source #
Typed executed statement.
executed :: ExecutedStatement a -> Statement Source #
Untyped executed statement.
result :: ExecutedStatement a -> Integer Source #
Result of HDBC execute.
executeBound :: BoundStatement a -> IO (ExecutedStatement a) Source #
Typed execute operation.
execute :: ToSql SqlValue p => PreparedStatement p a -> p -> IO (ExecutedStatement a) Source #
Bind parameters, execute prepared statement and get executed statement.
prepareNoFetch :: (UntypeableNoFetch s, IConnection conn) => conn -> s p -> IO (PreparedStatement p ()) Source #
Generalized prepare inferred from UntypeableNoFetch
instance.
executeBoundNoFetch :: BoundStatement () -> IO Integer Source #
Typed execute operation. Only get result.
executeNoFetch :: ToSql SqlValue a => PreparedStatement a () -> a -> IO Integer Source #
Bind parameters, execute prepared statement and get execution result.
runNoFetch :: (UntypeableNoFetch s, IConnection conn, ToSql SqlValue a) => conn -> s a -> a -> IO Integer Source #
Prepare and run sequence for polymorphic no-fetch statement.
mapNoFetch :: (UntypeableNoFetch s, IConnection conn, ToSql SqlValue a) => conn -> s a -> [a] -> IO [Integer] Source #
Prepare and run it against each parameter list.
Deprecated.
executePrepared :: ToSql SqlValue p => PreparedStatement p a -> p -> IO (ExecutedStatement a) Source #
Deprecated: use execute
instead of this.
Deprecated.
runPreparedNoFetch :: ToSql SqlValue a => PreparedStatement a () -> a -> IO Integer Source #
Deprecated: use executeNoFetch
instead of this.
Deprecated.