package freetds
Module Freetds.DblibSource
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 ->
dbprocessconnect server: open a connection to the given database server.
Executing SQL queries and getting the results
Send the SQL command to the server and wait for an answer.
Warning: There is one absolutely crucial, inflexible, unalterable requirement: the application must process all rows produced by the query. Before the dbprocess can be used for another query, the application must either fetch all rows, or cancel the results and receive an acknowledgement from the server.
Cancel the query currently being retrieved, (retriving and) discarding all pending rows.
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.
colname conn c returns the name of a regular result column c. The first column has number 1.
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
Get count of rows processed.
- for insert/update/delete, count of rows affected.
- for select, count of rows returned, after all rows have been fetched.
Error handling
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
*)dbprocessis still alive.| PROGRAM(*Coding error in user program.
*)| RESOURCE(*Running out of resources—the
*)dbprocessmay be dead.| COMM(*Failure in communication with Server—the
*)dbprocessis dead.| FATAL(*Fatal error—the
*)dbprocessis dead.| CONSISTENCY(*Internal software error—please open an issue.
*)
Error(severity, message) is raised on dblib errors. You can change the reaction to some errors by installing your own handler with err_handler.
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.
msg_handler f installs f as the default message handler for messages coming from the server. f is given the severity, the line number, and the message.
settime seconds Set the number of seconds that DB-Library will wait for a server response to a SQL command. If not response is obtained within that period, raise Error(TIME, _).