Class virtual Dbi.statement


class virtual statement : connection -> object  end

method virtual execute : arg_t list -> unit
Execute the statement with the given list of arguments substituted for ? placeholders in the query string.

This command can throw a variety of SQL-specific exceptions.

method virtual fetch1 : string array
The statement expects exactly one tuple to be returned from the query. This returns the tuple, or throws Not_found if no tuple is returned by the database.
method fetchall : string array list
This returns a list of all tuples returned from the query. Note that this is less efficient than reading them one at a time, or using bind_columns and next.
method iter : (string array -> unit) -> unit
Iterate over the result tuples.
method map : 'a. (string array -> 'a) -> 'a list
Map over the result tuples.
method fold_left : 'b. ('b -> string array -> 'b) -> 'b -> 'b
Fold left over the result tuples.
method fold_right : 'c. (string array -> 'c -> 'c) -> 'c -> 'c
Fold right over the result tuples. NB: not tail recursive.
method virtual bind_columns : ref_t list -> unit
This method binds result columns to variables (references). Subsequent calls to next will set those references for each tuple returned. Setting references is much more efficient than using the fetch methods, particularly when returning large objects.
method virtual next : bool
Returns the next row. You would normally want to call bind_columns first so that you can actually retrieve the value of each column. next returns true if a rows was returned or false otherwise.
method virtual serial : string -> int
If the statement is an INSERT and has been executed, then some databases support retrieving the serial number of the INSERT statement (assuming there is a SERIAL column or SEQUENCE attached to the table). The string parameter is the sequence name, which is only required by some database types. See the specific documentation for your database for more information.
method finish : unit
"Finishes" the statement. This basically just frees up any memory associated with the statement (this memory would be freed up by the GC later anyway). After calling finish you may call execute to begin executing another query.
method connection : connection
Return the database handle associated with this statement handle.