tfsrdbc/rdbcTfsAlloc.c
#include "sqlrtypes.h"
RDM_RETCODE exampleTfs_rdbcTfsAlloc (const char *databaseName)
{
RDM_TFS tfs;
SQLHENV hEnv;
SQLHDBC hDbc;
char connectStrIn[255];
char connectStrOut[255];
SQLSMALLINT outLen;
/* This creates an embedded TFS handle */
rc = rdm_rdmAllocTFS (&tfs);
if (rc == sOKAY)
{
rc = rdm_tfsSetOptions (tfs, "tfstype=embed");
if (rc == sOKAY)
{
rc = rdm_tfsInitialize (tfs);
}
if (rc == sOKAY)
{
}
else
{
ret = SQL_ERROR;
}
}
if (SQL_SUCCEEDED (ret))
{
ret = SQLAllocHandle (SQL_HANDLE_ENV, NULL, &hEnv);
if (SQL_SUCCEEDED (ret))
{
ret = SQLAllocHandle (SQL_HANDLE_DBC, hEnv, &hDbc);
if (SQL_SUCCEEDED (ret))
{
/* Pass the TFS handle to the ODBC driver */
if (SQL_SUCCEEDED (ret))
{
/* Connect to the TFS and open the database */
sprintf (connectStrIn, "databases=%s", databaseName);
hDbc, NULL, (SQLTCHAR *) connectStrIn, SQL_NTS,
(SQLTCHAR *) connectStrOut, sizeof (connectStrOut),
if (SQL_SUCCEEDED (ret))
{
(void) SQLDisconnect (hDbc);
}
else
{
SQLINTEGER native;
(void) SQLGetDiagRec (
SQL_HANDLE_DBC, hDbc, 1, NULL, &native, NULL, 0,
NULL);
rc = (RDM_RETCODE) native;
}
}
}
}
(void) rdm_tfsFree (tfs);
}
return rc;
}
void * SQLPOINTER
Definition: sqltypes.h:66
#define SQL_ERROR
\RDBC Return Code
Definition: sql.h:52
RDM_RETCODE rdm_rdmAllocTFS(RDM_TFS *phTFS)
Allocate a TFS handle.
#define SQL_ATTR_RDM_TFS_HANDLE
Definition: sqlrext.h:119
int32_t SQLINTEGER
Definition: sqltypes.h:57
RDBC_EXPORT SQLRETURN SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
Frees resources associated with a specific environment, connection, statement, or descriptor handle.
RDBC_EXPORT SQLRETURN SQLDisconnect(SQLHDBC ConnectionHandle)
Closes the connection associated with a specific connection handle.
RDBC_EXPORT SQLRETURN SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE *OutputHandle)
Allocates an environment, connection, statement, or descriptor handle.
#define SQL_HANDLE_ENV
Definition: sql.h:82
Header for RDM ODBC types.
#define SQL_DRIVER_NOPROMPT
Definition: sqlext.h:1733
#define SQL_NTS
Definition: sql.h:64
RDBC_EXPORT SQLRETURN SQLDriverConnect(SQLHDBC ConnectionHandle, SQLHWND WindowHandle, const SQLCHAR *InConnectionString, SQLSMALLINT StringLength1, SQLCHAR *OutConnectionString, SQLSMALLINT BufferLength, SQLSMALLINT *StringLength2Ptr, SQLUSMALLINT DriverCompletion)
Driver Connect.
@ sOKAY
Definition: rdmretcodetypes.h:96
int16_t SQLSMALLINT
Definition: sqltypes.h:55
#define SQL_SUCCEEDED(rc)
Definition: sql.h:58
RDBC_EXPORT SQLRETURN SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER StringLength)
Set an attribute of the \RDBC connection.
RDBC_EXPORT SQLRETURN SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT RecNumber, SQLCHAR *Sqlstate, SQLINTEGER *NativeError, SQLCHAR *MessageText, SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
Obtain the information about multiple diagnostic record fields.
#define SQL_HANDLE_DBC
Definition: sql.h:83
#define SQL_SUCCESS
\RDBC Return Code
Definition: sql.h:43
struct RDM_TFS_S * RDM_TFS
RDM TFS Handle.
Definition: rdmtfstypes.h:21
#define SQL_IS_POINTER
Definition: sqlext.h:243
RDM_RETCODE rdm_tfsFree(RDM_TFS hTFS)
Terminate a TFS service.
int16_t SQLRETURN
Definition: sqltypes.h:67
RDM_RETCODE rdm_tfsSetOptions(RDM_TFS tfs, const char *optString)
Set TFS options.
RDM_RETCODE
RDM status and error return codes.
Definition: rdmretcodetypes.h:44
RDM_RETCODE rdm_tfsInitialize(RDM_TFS tfs)
Initialize a RDM_TFS instance.