Qore odbc Module  1.0.0
ODBC Functions

Functions

hash Qore::odbc::odbc_bind (softint type, auto value)
 Creates a hash data structure understood by the ODBC DBI driver when binding values in SQL queries that allows programmers to directly specify the ODBC data type for the bind. More...
 

Detailed Description

Function Documentation

◆ odbc_bind()

hash Qore::odbc::odbc_bind ( softint  type,
auto  value 
)

Creates a hash data structure understood by the ODBC DBI driver when binding values in SQL queries that allows programmers to directly specify the ODBC data type for the bind.

Use the Type Constants for odbc_bind() to specify the ODBC data type for the bind. If the value to bind is NOTHING or NULL, a NULL will be bound as the value, regardless of the ODBC type code provided as the first argument.

Code Flags:
RET_VALUE_ONLY
Parameters
typethe type code for the ODBC type to bind
valuethe value to bind
Returns
The hash returned by the function encodes the desired ODBC type for the bind and the value for binding in the "^odbct^" and "^value^" keys
Example:
# we use odbc_bind() to bind a SQL_DATE type by value, otherwise the ODBC module would try to send the date as SQL_TIMESTAMP instead which could change the date value depending on currently set timezone and timezone of the ODBC connection
date d = 2016-1-14;
db.exec("INSERT INTO table_abc (id, dt) VALUES (%v, %v)", 42, odbc_bind(ODBCT_DATE, d));
Exceptions
DBI:ODBC:BIND-ERRORif the type argument is 0 this exception is raised