ODBCConnection
ODBCConnection — allocates a connection handle.
class ODBCConnection ODBCHandle
{
__stmt;
h;
handle;
type;
}
ODBCHandle
<-- ODBCConnection
This class allocates a connection handle. It corresponds to using the value
SQL_HANDLE_DBC for the
HandleType of the SQLAllocHandle function.
This class provides conversion functions
(QueryToClass,
QueryToTempClass and
ClassFromColumns, details below) to map an ODBC
response into a Gamma class. They are all variations on constructing a list of
class instances, where each row in the ODBC result maps to an instance of the
class. Each column name maps to a member variable in the class, and each value
in the row maps to the value of the member variable matching the corresponding
column name.
For example, if this is the ODBC result:
Name | Value | Timestamp point1 | 1 | 2025-01-22 12:00:00 point2 | 2 | 2025-01-22 12:00:01
and this is the class definition:
class MyDataClass
{
Name;
Value;
Timestamp;
} then the goal of these functions is to create 2 instances of
MyDataClass, where their Name,
Value and Timestamp values are the
corresponding values from each row of the query result.
The implementation of these functions can be found in C:\Program
Files\Cogent\Cogent DataHub\require\ODBCSupport.g
These functions are identical to the corresponding C or C++ functions, as noted.
![]() | |
We have attempted to link to Microsoft function documentation for these, but you may need to search. |
AddColumn (tablename, column, type, default_val,
allow_null)
corresponds to AddColumn.
AllocDescriptor ()
corresponds to AllocDescriptor.
AllocStatement ()
corresponds to SQLAllocStmt.
ClassFromColumns (symclassname, superclass,
columns)
This method is used by QueryToTempClass
(see below) to construct the class based on the column definitions
returned from an ODBC query. symclassname is a
symbol that will be the name of the temporary class. This name does
not need to be unique. superclass is the same as
for QueryToTempClass.
columns is the column set as returned from
the ODBC query. See also Conversion Functions, above.
ClassFromTable (symclassname, superclass,
tablename)
corresponds to ClassFromTable.
ClassesFromTables (superclass, verbose?=nil)
corresponds to ClassesFromTables.
Connect (ServerName, UserName, Authentication)
corresponds to SQLConnect.
CreateTable (tablename, columns...)
corresponds to CreateTable.
Delete (row)
corresponds to Delete.
Disconnect ()
corresponds to SQLDisconnect.
DropTable (tablename)
corresponds to DropTable.
EndTran (CompletionType)
corresponds to SQLEndTran.
Error ()
corresponds to SQLError.
GetOneColumn (query_string)
corresponds to GetOneColumn.
GetOneValue (query_string)
corresponds to GetOneValue.
Insert (row)
corresponds to Insert.
MakeClass (symclassname, superclass, ivars, tablename,
primary_key)
corresponds to MakeClass.
MapClassFromResponse (klass, response)
corresponds to MapClassFromResponse.
Query (query_string)
corresponds to Query.
QueryAndStore (query_string)
corresponds to QueryAndStore.
QueryToClass (klass, query_string)
This method will produce an array of instances of
klass, where the values from the query
are mapped to the member variables of the class. See also Conversion
Functions, above. Example:
local instanceArray = conn.QueryToClass(MyDataClass, "select * from mytable");
QueryToTempClass (superclass, query)
This method will create a temporary class on the fly, such that the member variables of the class match the column names of the query result. If superclass is non-nil then it must be a class. The newly created class will be derived from the superclass. The return value is an array of instances of the newly created class. See also Conversion Functions, above. Example:
local instanceArray = conn.QueryToTempClass(nil, "select * from mytable");
ReQuery (row)
corresponds to ReQuery.
Statement ()
corresponds to Statement.
StoreResult ()
corresponds to StoreResult.
Update (row)
corresponds to Update.
(The following functions are inherited from: ODBCHandle)
GetDiagRec ()
corresponds to SQLGetDiagRec.