Rel_sql.Stmt
Typed SQL statements.
See the SQL statement typing howto for a short introduction.
The type for SQL statement arguments (parameters).
val pp_arg : Stdlib.Format.formatter -> arg -> unit
pp_arg
formats an argument with Rel.Type.value_pp
.
The type for a closed (all arguments are bound) SQL statement returning rows of type 'r
. Note that this must be a single statement.
v sql rev_args result
is a closed statement with srouce sql
, revered list of arguments (parameters) rev_args
and yielding rows of type result
.
val src : 'r t -> string
src st
is the source SQL statement of st
.
val pp_src : Stdlib.Format.formatter -> 'r t -> unit
pp_src
formats the statement's source.
val pp : Stdlib.Format.formatter -> 'r t -> unit
pp ppf st
formats the statement's source and its arguments.
val func : string -> 'a func -> 'a
func sql f
is the binding function of f
used on the source SQL statement sql
.
ret st row
is an open SQL statement st
returning values of type row
.
val arg : 'a Rel.Type.t -> 'b func -> ('a -> 'b) func
arg t f
binds a new variable of type t
to f
.
val (@->) : 'a Rel.Type.t -> 'b func -> ('a -> 'b) func
t @-> f
is arg t f
.
unit
is ret
Rel.Row.empty
.
The following constants get redefined here to allow consise specification with the Sql.Stmt.()
notation.
val bool : bool Rel.Type.t
bool
is Rel.Type.Bool
.
val int : int Rel.Type.t
int
is Rel.Type.Int
.
val int64 : int64 Rel.Type.t
int64
is Rel.Type.Int64
.
val float : float Rel.Type.t
float
is Rel.Type.Float
.
val text : string Rel.Type.t
text
is Rel.Type.Text
.
val blob : string Rel.Type.t
blob
is Rel.Type.Blob
.
val option : 'a Rel.Type.t -> 'a option Rel.Type.t
option t
is Rel.Type.Option
t
.
See the this section of the SQL statement typing howto.
val proj : ('r -> 'a) -> 'a Rel.Type.t -> ('r -> 'b) func -> ('r -> 'b) func
proj p t
binds the projection p
of a value of type t
.