Library
Module
Module type
Parameter
Class
Class type
Low level binding to the DB-lib part of freetds. These bindings mimic the C API and therefore some functions must be used in the right order. Look at the FreeTDS User Guide and Sybase documentation for fine points. Use OCamlDBI with the freetds driver for an easier interaction with such databases.
Value that contains all information needed by Freetds.Dblib
to manage communications with the server.
type version =
| V42
Works with all products, subject to limitations.
*)| V46
| V70
Includes support for the extended datatypes in SQL Server 7.0 (such as char/varchar fields of more than 255 characters), and support for Unicode.
*)| V71
Include support for bigint (64 bit integers), variant and collation on all fields. Collation is not widely used.
*)| V72
Includes support for varchar(max), varbinary(max), xml datatypes and MARS.
*)| V73
Includes support for time, date, datetime2, datetimeoffset.
*)| V74
Includes support for session recovery.
*)Protocol version. Note that the protocol version is chosen in your freetds.conf file or via the environment variable TDSVER (which supersedes the configuration file). See Choosing a TDS protocol version to help you choose. Be warned that 4.x versions of the protcol do not allow empty strings which will be returned as strings of length 1.
val connect :
?user:string ->
?password:string ->
?charset:string ->
?language:string ->
?application:string ->
?version:version ->
string ->
dbprocess
connect server
: open a connection to the given database server.
val close : dbprocess -> unit
close conn
close the connection conn
to the server.
val use : dbprocess -> string -> unit
use conn name
change the current database to name
.
val name : dbprocess -> string
name conn
returns the name of the current database.
val sqlexec : dbprocess -> string -> unit
Send the SQL command to the server and wait for an answer.
val cancel : dbprocess -> unit
Cancel the current command batch.
val canquery : dbprocess -> unit
Cancel the query currently being retrieved, (retriving and) discarding all pending rows.
val results : dbprocess -> bool
results conn
returns true
if some results are available and false
if the query produced no results. There may be several results if COMPUTE clauses are used. One MUST CALL this function before trying to retrieve any rows.
val numcols : dbprocess -> int
Return number of regular columns in a result set.
val colname : dbprocess -> int -> string
colname conn c
returns the name of a regular result column c
. The first column has number 1.
val string_of_col_type : col_type -> string
Returns a string description of the column type.
type data =
| NULL
| STRING of string
| TINY of int
| SMALL of int
| INT of int
| INT32 of int32
| INT64 of int64
| FLOAT of float
| DATETIME of int * int * int * int * int * int * int * int
(year, month, day, hour, minute, second, millisecond, zone)
*)| MONEY of float
| BIT of bool
| BINARY of string
| NUMERIC of string
| DECIMAL of string
val string_of_data : data -> string
val count : dbprocess -> int
Get count of rows processed.
type severity =
| INFO
Informational, non-error.
*)| USER
User error.
*)| NONFATAL
Non-fatal error.
*)| CONVERSION
Error in DB-Library data conversion.
*)| SERVER
The Server has returned an error flag.
*)| TIME
We have exceeded our timeout period while waiting for a response from the Server—the dbprocess
is still alive.
| PROGRAM
Coding error in user program.
*)| RESOURCE
Running out of resources—the dbprocess
may be dead.
| COMM
Failure in communication with Server—the dbprocess
is dead.
| FATAL
Fatal error—the dbprocess
is dead.
| CONSISTENCY
Internal software error—please open an issue.
*)exception Error of severity * string
Error(severity, message)
is raised on dblib errors. You can change the reaction to some errors by installing your own handler with err_handler
.
val err_handler : (severity -> int -> string -> unit) -> unit
err_handler f
installs f
as the default error handler for non-OS related errors and errors not coming from the server. f
is given the severity
, the number of the error (see the 400 or so error numbers sybdb.h, macros SYBE...) and the message.