The ODBC API is divided into three parts:
All functions described are synchronous.
The interface supports all ODBC defined SQL data types except binaries.
They are all mapped on Erlang strings.
The type string()
is a list()
of integers representing ASCII
codes. The type
boolean()
is either the macro ?SQL_TRUE
or the macro ?SQL_FALSE
.
The default Timeout for all functions is 5000 ms, unless otherwise stated.
start_link(Args, Options) ->
start_link(ServerName, Args, Options) -> Result
Args = [Arg]
Arg = {buffer_size, integer()} |
{max_len_data, integer()}|
{max_len_err_msg, integer()} |
{max_len_str, integer()}
{buffer_size, integer()}
: The initial size of the buffer
through which communication with the C node is done.
The value does not limit the amount of data that can pass in
either
direction of a function call, since the buffer will grow
dynamically. The default is 32 kb. The minimum is 4 kb.
{max_len_data, integer()}
: The maximum length, including
null-termination, of
table data,
returned from ODBC. This value must be chosen with the buffer
size in mind.
The default is 8 kb. The argument is used only by the Utility API.
NOTE: The data source or driver may have a
lower limit for the maximum size of returned data. This
limit
is the value of the optional statement attribute
SQL_ATTR_MAX_LENGTH (see [1]).
{max_len_err_msg, integer()}
: The maximum length, including
null-termination, of the
message part of ODBC error messages. This value must be
chosen with the buffer
size in mind.
The default is 1 kb. The argument is used only by the
Utility API.
{max_len_str, integer()}
: The maximum length,
including null-termination, of other
strings passed from ODBC to the
ODBC server (e.g. column names). The value does not limit the size of
returned table values. It must be chosen with the
buffer size in mind. The default is 1 kb. The argument is used
only by the Utility API.Options = [Opt]
Opt = {timeout, integer()} |{debug, [Dbg]}
timeout
: The time in ms allowed for initialisation (see
gen_server
). debug
: Debug options. Dbg = trace | log | statistics | {log_to_file, FileName} |
{install, {Func, FuncState}}
gen_server
and sys
.ServerName = {local, atom()} | {global, atom()}
Result = {ok, pid()} | {error, Reason}
Reason = {already_started, pid()} | timeout | {no_c_node, Info}
Info = string()
Starts a new ODBC server process, registers it with the supervisor, and links it to the calling process. Opens a unique IDL connection to a new C node on the local host, using the same cookie as is used by the node of the calling process. Links to the process on the C node.
There is no default timeout value. Not using the timeout
option is equivalent to having an infinite timeout value. |
stop(Server) ->
stop(Server, Timeout) -> ok
Server = pid() | Name | {global, Name} | {Name, Node}
Timeout = integer() | infinity
Stops the ODBC server process as soon as all already submitted requests have been processed. The C node is also stopped.
The Utility API uses three maximum string length parameters: the maximum
data string length (max_len_data), the maximum error message length
(max_len_err_msg), and the maximum length of 'other strings'
(e.g. column names) passed from ODBC (max_len_str). These can be set
in the call to start_link/[2, 3]
, but there are default values.
Errors reported by the ODBC API are returned in lists. The relative order of
these errors is the same as specified in [1]. Warnings are always ignored and
execution proceeds. Should an error occur, execution stops.
init_env(Server) ->
init_env(Server, Timeout) ->
{ok, RefEnvHandle} |
{error, {Fcn, [Reason]}}
Server = pid() | Name | {global, Name} | {Name, Node}
Timeout = integer() | infinity
RefEnvHandle = term()
Fcn = atom()
Reason = {SqlState, MoreInfo}
SqlState = string()
MoreInfo = {NativeCode, Msg, LenMsg}
NativeCode = string()
Msg = string()
LenMsg = integer()
Msg
before truncation.Initialises the ODBC environment on the C node.
connect(Server, RefEnvHandle, ConnectStr) ->
connect(Server, RefEnvHandle, ConnectStr, Timeout) ->
connect(Server, RefEnvHandle, DSN, UID, PWD) ->
connect(Server, RefEnvHandle, DSN, UID, PWD, Timeout) ->
{ok, RefConnHandle} | {error, {Fcn, [Reason]}}
Server = pid() | Name | {global, Name} | {Name, Node}
RefEnvHandle = term()
init_env/[1,2]
.ConnectStr = string()
DSN = string()
UID = string()
PWD = string()
Timeout = integer() | infinity
RefConnHandle = term()
Fcn = atom()
Reason = {SqlState, MoreInfo}
SqlState = string()
MoreInfo = {NativeCode, Msg, LenMsg}
NativeCode = string()
Msg = string()
LenMsg = integer()
Msg
before truncation.Opens a connection to a data source. There can be only
one open data source connection per server.
connect/[3, 4]
is used when the information that can be
supplied through connect/[5, 6]
does not suffice.
The syntax to be used for |
execute_stmt(Server, RefConnHandle, Stmt) ->
execute_stmt(Server, RefConnHandle, Stmt, Timeout) ->
{updated, NRows} | {selected, [ColName], [Row]}
{error, {Fcn, [Reason]}}
Server = pid() | Name | {global, Name} | {Name, Node}
RefConnHandle = term()
connect/[3,4,5,6]
.Stmt = string()
Timeout = integer() | infinity
NRows = integer()
ColName = string()
Row = [Value]
Value = string() | null
Fcn = atom()
Reason = {SqlState, MoreInfo}
SqlState = string()
MoreInfo = {NativeCode, Msg, LenMsg}
NativeCode = string()
Msg = string()
LenMsg = integer()
Msg
before truncation.Executes a single SQL statement. All changes to the data source are, by default, automatically committed if successful. Data that is returned for SELECT statements is in string form.
|
disconnect(Server, RefConnHandle) ->
disconnect(Server, RefConnHandle, Timeout) ->
ok | {error, {Fcn, [Reason]}}
Server = pid() | Name | {global, Name} | {Name, Node}
RefConnHandle = term()
connect/[3,4,5,6]
.Timeout = integer() | infinity
Fcn = atom()
Reason = {SqlState, MoreInfo}
SqlState = string()
MoreInfo = {NativeCode, Msg, LenMsg}
NativeCode = string()
Msg = string()
LenMsg = integer()
Msg
before truncation.Closes the connection to a data source.
terminate_env(Server, RefEnvHandle) ->
terminate_env(Server, RefEnvHandle, Timeout) ->
ok | {error, {Fcn, [Reason]}}
Server = pid() | Name | {global, Name} | {Name, Node}
RefEnvHandle = term()
init_env/[1,2]
.Timeout = integer() | infinity
Fcn = atom()
Reason = {SqlState, MoreInfo}
SqlState = string()
MoreInfo = {NativeCode, Msg, LenMsg}
NativeCode = string()
Msg = string()
LenMsg = integer()
Msg
before truncation.Cleans up the ODBC environment on the C node.
To use the Basic API it is necessary to gain a comprehensive understandingof ODBC by studying [1]. ODBC defines the concept of deferred buffers. A deferred buffer is one that exists longer than one function call, so it can be used in several calls. Deferred buffers come in pairs: one data buffer and one length/indicator buffer. The length/indicator buffer is used for communicating the length of data in the data buffer, or to indicate something about the data (e.g. that it is a null-value). The Basic API handles these buffers accordingly: they are allocated, deallocated, read, and written pair-wise.
sql_alloc_handle(Server, HandleType, RefInputHandle) ->
sql_alloc_handle(Server, HandleType, RefInputHandle,
Timeout) ->
{Result, RefOutputHandle}
Server = pid() | Name | {global, Name} | {Name, Node}
HandleType = ?SQL_HANDLE_ENV | ?SQL_HANDLE_DBC |
?SQL_HANDLE_STMT
RefInputHandle = term() | ?SQL_NULL_HANDLE
?SQL_NULL_HANDLE
. When allocating a connection handle the
argument must be an environment handle and when allocating a
statement handle it must be a connection handle.Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_SUCCESS_WITH_INFO |
?SQL_INVALID_HANDLE | ?SQL_ERROR
RefOutputHandle = term() | ?SQL_NULL_HENV |
?SQL_NULL_HDBC | ?SQL_NULL_HSTMT
Allocates memory for an environment, connection, or
statement handle. See SQLAllocHandle in [1].
Differences from the ODBC Function:
Allocation of descriptor handles is not supported.
The parameters Server
and Timeout
have been added.
The ODBC output parameter OutputHandlePtr
has
been changed into the returned value RefOutputHandle
.
Connection pooling is not supported.
sql_bind_col(Server, RefStmtHandle, ColNum, RefBuf) ->
sql_bind_col(Server, RefStmtHandle, ColNum, RefBuf,
Timeout) ->
Result
Server = pid() | Name | {global, Name} | {Name, Node}
RefStmtHandle = term()
ColNum = integer()
RefBuf = integer() | ?NULL_REF
?NULL_REF
removes the binding between a buffer and
a column.Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_SUCCESS_WITH_INFO |
?SQL_INVALID_HANDLE | ?SQL_ERROR
Assigns storage and data type for a column in a result
set (binds a buffer to a column). See SQLBindCol in [1].
Buffers/columns can also be unbound.
The memory associated with |
Differences from the ODBC Function:
Neither binding of arrays nor the use of binding offsets
is supported. It is not possible to unbind the data buffer
without also unbinding the length/indicator buffer. The
parameters Server
and Timeout
have been
added. The input parameters TargetType
,
TargetValuePtr
, BufferLength
, and
StrLen_or_IndPtr
of the ODBC function have
been replaced
with the RefBuf
parameter (which represents the same
data).
sql_close_cursor(Server, RefStmtHandle) ->
sql_close_cursor(Server, RefStmtHandle, Timeout) ->
Result
Server = pid() | Name | {global, Name} | {Name, Node}
RefStmtHandle = term()
Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_SUCCESS_WITH_INFO |
?SQL_INVALID_HANDLE | ?SQL_ERROR
Closes a cursor that has been opened on a statement
and discards pending results. See SQLCloseCursor in [1].
Differences from the ODBC Function:
The parameters Server
and Timeout
have
been added.
sql_connect(Server, RefConnHandle, DSN, UID, Auth) ->
sql_connect(Server, RefConnHandle, DSN, UID, Auth,
Timeout) ->
Result
Server = pid() | Name | {global, Name} | {Name, Node}
RefConnHandle = term()
DSN = string()
UID = string()
Auth = string()
Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_SUCCESS_WITH_INFO |
?SQL_INVALID_HANDLE | ?SQL_ERROR
Establishes a connection to a driver and a data source.
See SQLConnect in [1].
Differences from the ODBC Function:
Connection pooling is not supported.
The parameters Server
and Timeout
have been added.
The input parameters NameLength1
,
NameLength2
, and NameLength3
of the
ODBC function have been excluded.
sql_describe_col(Server, RefStmtHandle, ColNum,
BufLenColName) ->
sql_describe_col(Server, RefStmtHandle, ColNum,
BufLenColName, Timeout) ->
{Result,{ColName, LenColName}, SqlType, ColSize, DecDigs, Nullable}
Server = pid() | Name | {global, Name} | {Name, Node}
RefStmtHandle = term()
ColNum = integer()
BufLenColName = integer()
ColName
buffer. Allow room for
null-termination.Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_SUCCESS_WITH_INFO |
?SQL_INVALID_HANDLE | ?SQL_ERROR
ColName = string()
LenColName = integer()
ColName
. An ODBC SQL data type
(ODBC supported data types are supplied through macros).SqlType = integer()
ColSize = integer()
DecDigs = integer()
Nullable = ?SQL_NO_NULLS | ?SQL_NULLABLE | ?SQL_NULLABLE_UNKNOWN
Returns the result descriptor -- column name, type,
column size, decimal digits, and nullability -- for one column
in the result set. See SQLDescribeCol in [1].
To decide the buffer size (how many characters or
bytes) needed to retrieve data for the column it is necessary
to calculate the display size (see also appendix D in [1]).
The function display_size(SqlType, ColSize) ->
integer()
does the calculation. The input
parameters are returned by sql_describe_col/[4, 5]
.
Differences from the ODBC Function:
The function does not support retrieval of bookmark
column data.
The parameters Server
and Timeout
have
been added. The output parameters ColumnName
,
NameLengthPtr
, DataTypePtr
,
ColumnSizePtr
, DecimalDigitsPtr
, and
NullablePtr
of the ODBC function have been changed
into the returned values ColName
,
LenColName
, SqlType
, ColSize
,
DecDigs
, and Nullable
.
BufLenColName
must be > 0.
sql_disconnect(Server, RefConnHandle) ->
sql_disconnect(Server, RefConnHandle, Timeout) ->
Result
Server = pid() | Name | {global, Name} | {Name, Node}
RefConnHandle = term()
Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_SUCCESS_WITH_INFO |
?SQL_INVALID_HANDLE | ?SQL_ERROR
Closes the connection associated with a specific
connection handle. See SQLDisconnect in [1].
Differences from the ODBC Function:
Connection pooling is not supported.
The parameters Server
and Timeout
have been added.
sql_driver_connect(Server, RefConnHandle, InConnStr,
BufLenOutConnStr, DrvCompletion) ->
sql_driver_connect(Server, RefConnHandle, InConnStr,
BufLenOutConnStr, DrvCompletion, Timeout) ->
{Result, {OutConnStr, LenOutConnStr}}
Server = pid() | Name | {global, Name} | {Name, Node}
RefConnHandle = term()
InConnStr = string()
BufLenOutConnStr = integer()
OutConnStr
buffer. Allow room for
null-termination.DrvCompletion = ?SQL_DRIVER_NOPROMPT
Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_SUCCESS_WITH_INFO |
?SQL_INVALID_HANDLE | ?SQL_ERROR | ?SQL_NO_DATA
OutConnStr = string()
LenOutConnStr = integer()
OutConnStr
before truncation.Establishes a connection to a driver and a data sourc,
which needs more connection information than SQLConnect
offers. See SQLDriverConnect in [1].
Differences from the ODBC Function:
The function does not support prompting with pop-ups,
so the connection string supplied must be complete or, at least,
complete enough for connecting.
The parameters Server
and Timeout
have
been added. The input parameters WindowHandle
and StringLength1
of the ODBC function have been
excluded. The output parameters
OutConnectionString
and StringLength2Ptr
have been changed into the returned values
OutConnStr
and LenOutConnStr
.
BufLenOutConnStr
must be > 0.
sql_end_tran(Server, HandleType, RefHandle,
ComplType) ->
sql_end_tran(Server, HandleType, RefHandle, ComplType,
Timeout) ->
Result
Server = pid() | Name | {global, Name} | {Name, Node}
HandleType = ?SQL_HANDLE_ENV | ?SQL_HANDLE_DBC
RefHandle = term()
ComplType = ?SQL_COMMIT | ?SQL_ROLLBACK
Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_SUCCESS_WITH_INFO |
?SQL_INVALID_HANDLE | ?SQL_ERROR
Requests a commit or rollback operation for all active operations on all statement handles associated with a connection. It can also request that a commit or rollback operation be performed for all connections associated with the environment handle. See SQLEndTran in [1].
Rollback of transactions may be unsupported by core level drivers. |
Differences from the ODBC Function:
The parameters Server
and Timeout
have been added.
sql_exec_direct(Server, RefStmtHandle, Stmt) ->
sql_exec_direct(Server, RefStmtHandle, Stmt, Timeout) ->
Result
Server = pid() | Name | {global, Name} | {Name, Node}
RefStmtHandle = term()
Stmt = string()
Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_SUCCESS_WITH_INFO |
?SQL_INVALID_HANDLE | ?SQL_ERROR | ?SQL_NEED_DATA | ?SQL_NO_DATA
Executes a statement. See SQLExecDirect in [1].
Differences from the ODBC Function:
?SQL_NO_DATA
is returned only in connection with
positioned updates, which are not supported.
The parameters Server
and Timeout
have
been added. The input parameter TextLength
of
the ODBC function has been excluded.
sql_fetch(Server, RefStmtHandle) ->
sql_fetch(Server, RefStmtHandle, Timeout) ->
Result
Server = pid() | Name | {global, Name} | {Name, Node}
RefStmtHandle = term()
Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_SUCCESS_WITH_INFO |
?SQL_INVALID_HANDLE | ?SQL_ERROR | ?SQL_NO_DATA
Fetches a row of data from a result set. The driver
returns data for all columns that were bound to storage
locations with sql_bind_col/[4, 5]
. See SQLFetch in [1].
Differences from the ODBC Function:
The parameters Server
and Timeout
have
been added.
sql_free_handle(Server, HandleType, RefHandle) ->
sql_free_handle(Server, HandleType, RefHandle, Timeout) ->
Result
Server = pid() | Name | {global, Name} | {Name, Node}
HandleType = ?SQL_HANDLE_ENV | ?SQL_HANDLE_DBC |
?SQL_HANDLE_STMT
RefHandle = term()
Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_INVALID_HANDLE | ?SQL_ERROR
Releases a handle and frees all resources associated
with it. See SQLFreeHandle in [1].
Differences from the ODBC Function:
The function does not support deallocation of descriptor
handles. The parameters Server
and Timeout
have
been added.
sql_get_connect_attr(Server, RefConnHandle, Attr,
BufType) ->
sql_get_connect_attr(Server, RefConnHandle, Attr,
BufType, Timeout) ->
{Result, Value}
Server = pid() | Name | {global, Name} | {Name, Node}
RefConnHandle = term()
Attr = integer()
BufType = {?SQL_C_CHAR, BufLen} | ?SQL_C_ULONG |
{?SQL_C_ULONG, IntType}
BufLen = integer()
IntType = ?SQL_IS_UINTEGER | ?SQL_IS_INTEGER
Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_SUCCESS_WITH_INFO |
?SQL_INVALID_HANDLE | ?SQL_ERROR | ?SQL_NO_DATA
Value = {CharValue, LenCharValue} | NumValue
CharValue = string()
LenCharValue = integer()
NumValue = integer()
Returns the current setting of a connection attribute.
See SQLGetConnectAttr in [1].
Differences from the ODBC Function:
Only the following attributes, and their possible values,
are supported (through macros). More information can be
found under SQLSetConnectAttr in [1]. Driver-specific
attributes are not supported through macros, but can be
retrieved, if they are of character or signed/unsigned
long integer types.
According to [1], BufLen
(BufferLength) can be set to
?SQL_NTS
. This is probably not correct, since it would
make it impossible for the driver to detect
that data needs to be truncated. Hence, the ?SQL_NTS
value has been disallowed.
The function takes a BufType
parameter to distinguish
between character type attributes and numeric type
attributes. For character data the maximum string length
must be supplied (allow room for null-termination).
For driver-specific numeric type attributes, a subtype
must be supplied. The returned value is either a tuple
containing the attribute string and its length, or an
integer, depending on the specified buffer type.
The parameters Server
and Timeout
have been added. The
output parameters ValuePtr
and StringLengthPtr
of the
ODBC function have been changed into the returned values
CharValue
and LenCharValue
for character
type attributes and NumValue
for integer types.
The input parameter BufferLength
has been
included in the BufTyp
e parameter.
BufLen
must be > 0.
sql_get_diag_rec(Server, HandleType, RefHandle, RecNum,
BufLenErrMsg) ->
sql_get_diag_rec(Server, HandleType, RefHandle, RecNum,
BufLenErrMsg, Timeout) ->
{Result, SqlState, NativeErr, {ErrMsg, LenErrMsg}}
Server = pid() | Name | {global, Name} | {Name, Node}
HandleType = ?SQL_HANDLE_ENV | ?SQL_HANDLE_DBC |
?SQL_HANDLE_STMT
RefHandle = term()
RecNum = integer()
BufLenErrMsg = integer()
ErrMsg
buffer (>0).
Allow room for null-termination.Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_SUCCESS_WITH_INFO |
?SQL_INVALID_HANDLE | ?SQL_ERROR | ?SQL_NO_DATA
SqlState = string()
NativeErr = integer()
ErrMsg = string(
LenErrMsg = integer()
ErrMsg
before truncation.Retrieves the current values of multiple fields of a
diagnostic record that contains error, warning, and
status information. See SQLGetDiagRec in [1].
Differences from the ODBC Function:
Retrieving information associated with descriptor handles
is not supported. The parameters Server
and Timeout
have
been added. The output parameters SqlState
,
NativeErrorPtr
, MessageText
, and
TextLengthPtr
of the ODBC
function have been changed into the returned values
SqlState
, NativeErr
,
ErrMsg
, and LenErrMsg
. BufLenErrMsg
must be > 0.
sql_num_result_cols(Server, RefStmtHandle) ->
sql_num_result_cols(Server, RefStmtHandle, Timeout) ->
{Result, ColCount}
Server = pid() | Name | {global, Name} | {Name, Node}
RefStmtHandle = term()
Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_SUCCESS_WITH_INFO |
?SQL_INVALID_HANDLE | ?SQL_ERROR
ColCount = integer()
Returns the number of columns in a result set.
See SQLNumResultCols in [1].
Differences from the ODBC Function:
The parameters Server
and Timeout
have
been added. The output parameter
ColumnCountPtr
of the ODBC function has been
changed into the returned
value ColCount
.
sql_row_count(Server, RefStmtHandle) ->
sql_row_count(Server, RefStmtHandle, Timeout) ->
{Result, RowCount}
Server = pid() | Name | {global, Name} | {Name, Node}
RefStmtHandle = term()
Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_SUCCESS_WITH_INFO |
?SQL_INVALID_HANDLE | ?SQL_ERROR
RowCount = integer()
Returns the number of rows affected by an UPDATE, INSERT,
or DELETE statement. See SQLRowCount in [1].
Differences from the ODBC Function:
The parameters Server
and Timeout
have been added.
The output parameter RowCountPtr
of the ODBC
function has been changed into the returned value
RowCount
.
sql_set_connect_attr(Server, RefConnHandle, Attr, Value,
BufType) ->
sql_set_connect_attr(Server, RefConnHandle, Attr, Value,
BufType, Timeout) ->
Result
Server = pid() | Name | {global, Name} | {Name, Node}
RefConnHandle = term()
Attr = integer()
sql_get_connect_attr/[4, 5]
or a driver-specific attribute. The attributes
defined by ODBC are supplied through
macros, but driver-specific attributes are not.Value = string() | integer()
BufType = ?SQL_C_CHAR | ?SQL_C_ULONG |
{?SQL_C_ULONG, IntType}
IntType = ?SQL_IS_UINTEGER | ?SQL_IS_INTEGER
Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_SUCCESS_WITH_INFO |
?SQL_INVALID_HANDLE | ?SQL_ERROR
Sets attributes that govern aspects of connections.
See SQLSetConnectAttr in [1]. The supported attributes are
listed under sql_get_connect_attr/[4, 5]
.
Driver-specific attributes are not supported through
macros, but can be set if they are strings or
signed/unsigned long integers.
Differences from the ODBC Function:
Only character and signed/unsigned long
integer attribute types are supported.
The parameters Server
and Timeout
have been
added. The input parameter StringLength
of
the ODBC function has been replaced with the input
parameter BufType
.
sql_set_env_attr(Server, RefEnvHandle, Attr, Value, BufType)
->
sql_set_env_attr(Server, RefEnvHandle, Attr, Value, BufType, Timeout) ->
Result
Server = pid() | Name | {global, Name} | {Name, Node}
RefEnvHandle = term()
Attr = integer()
Value = string() | intiger()
BufType = ?SQL_C_CHAR | ?SQL_C_ULONG
Timeout = integer() | infinity
Result = ?SQL_SUCCESS | ?SQL_SUCCESS_WITH_INFO |
?SQL_INVALID_HANDLE | ?SQL_ERROR
Sets attributes that govern aspects of environments. The following attributes, and their possible values, are supported (through macros). More information can be found under SQLSetEnvAttr in [1]. Other data types than character or unsigned long integer are not supported.
Differences from the ODBC Function:
Only character and unsigned long integer attribute types are supported.
The parameters Server
and Timeout
have been added. The
input parameter StringLength
of the ODBC function has been
replaced with the input parameter BufType
.
alloc_buffer(Server, BufCType, Size) ->
alloc_buffer(Server, BufCType, Size, Timeout) ->
{ok, RefBuf}
Server = pid() | Name | {global, Name} | {Name, Node}
BufCType = ?SQL_C_CHAR | ?SQL_C_BINARY
Size = integer()
Timeout = integer() | infinity
RefBuf = term()
Allocates a deferred data buffer and an associated length/indicator buffer.
dealloc_buffer(Server, RefBuf) ->
dealloc_buffer(Server, RefBuf, Timeout) ->
ok
Server = pid() | Name | {global, Name} | {Name, Node}
RefBuf = term()
Timeout = integer() | infinity
Deallocates a deferred data buffer and the associated length/indicator buffer.
read_buffer(Server, RefBuf) ->
read_buffer(Server, RefBuf, Timeout) ->
{ok, {Value, LenInd}}
Server = pid() | Name | {global, Name} | {Name, Node}
RefBuf = term()
Timeout = integer() | infinity
Value = string()
RefBuf
.LenInd = integer() | ?SQL_NULL_DATA | ?SQL_NO_TOTAL
RefBuf
.
Returns the contents of a deferred data buffer and its
associated length/indicator buffer. Used in connection
with sql_fetch/[2, 3]
.
Errors caused by inability to contact the C node,
allocate memory, or otherwise call ODBC functions cause
exceptions. Exceptions are common to all functions.
Errors caused by ODBC not being able to execute calls are
reported through returned errors.
These exceptions terminate the client only.
gen_server
.These cause the ODBC server, and the C node, to terminate as well:
[1]: Microsoft ODBC 3.0, Programmer's Reference and SDK Guide