package freetds

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
exception End_results
exception End_data
exception Cancelled
exception Cmd_fail
exception Datatype_not_implemented
type binding_buffer

I've added this type to be an opaque "void*" type that will return a sql_t

type context

Identifies the Client-Library context being initialized.

type connection

Contains information about a particular client/server connection.

type status = [
  1. | `CanBeNull
  2. | `Identity
  3. | `NoData
  4. | `Return
]
type column = {
  1. col_name : string;
  2. col_status : status list;
  3. col_buffer : binding_buffer;
}
type sql_t = [
  1. | `Bit of bool
  2. | `Tinyint of int
  3. | `Smallint of int
  4. | `Int of int32
  5. | `Text of string
  6. | `String of string
  7. | `Binary of string
  8. | `Float of float
  9. | `Datetime of string
  10. | `Decimal of string
  11. | `Null
]
val ctx_create : unit -> context

Context

Connection
val con_alloc : context -> connection
type string_property = [
  1. | `Appname
  2. | `Password
  3. | `Username
]

CS_APPNAME, CS_PASSWORD, and CS_USERNAME - there are others but I've never used them... Easy to add on demand; patches welcome

type prop_action = [
  1. | `Clear
  2. | `Get
  3. | `Set
]

CS_CLEAR CS_GET and CS_SET

val con_setstring : connection -> string_property -> string -> unit
val connect : connection -> string -> unit

connect conn servername connect to the server servername.

val close : ?force:bool -> connection -> unit
Command
type command

CS_COMMAND

val cmd_alloc : connection -> command
type cmd_type = [
  1. | `Lang
  2. | `Rpc
]

CS_LANG and CS_RPC - rpc is currently not really implemented

  • you'll notice no ct_param wrapper
type cmd_option = [
  1. | `NoRecompile
  2. | `Recompile
]

Options for compiling CS_NORECOMPILE and CS_RECOMPILE

val command : command -> cmd_type -> ?option:cmd_option -> string -> unit
val send : command -> unit
Results
type result_type = [
  1. | `Cmd_done
  2. | `Cmd_fail
  3. | `Cmd_succeed
  4. | `Param
  5. | `Row
  6. | `Status
]

Result types; usually we only care about Row

val results : command -> result_type
type resinfo_type = [
  1. | `Cmd_number
  2. | `Numdata
  3. | `Row_count
]
val res_info : command -> resinfo_type -> int
  • res_info cmd `Cmd_number returns the number of the command that generated the current result set.
  • res_info cmd `Numdata returns the number of columns in the current result set.
  • res_info cmd `Row_count returns the number of rows affected by the current command.
val fetch : command -> int
val bind : command -> ?maxlen:int -> int -> column
val buffer_contents : binding_buffer -> sql_t
Inline error handling
type severity =
  1. | Inform
  2. | Api_fail
  3. | Retry_fail
  4. | Resource_fail
  5. | Comm_fail
  6. | Internal_fail
  7. | Fatal
val get_messages : ?client:bool -> ?server:bool -> connection -> (severity * string) list
OCaml

Innovation. Community. Security.