tfsrdbc/rdbcTfsAlloc.c
#include "sqlrtypes.h"
RDM_RETCODE exampleTfs_rdbcTfsAlloc (const char *databaseName)
{
RDM_TFS tfs;
SQLRETURN ret{};
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_tfsInitialize (tfs);
if (rc == sOKAY)
{
ret = SQL_SUCCESS;
}
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) SQLFreeHandle (SQL_HANDLE_DBC, hDbc);
}
(void) SQLFreeHandle (SQL_HANDLE_ENV, hEnv);
}
(void) rdm_tfsFree (tfs);
}
return rc;
}
void * SQLPOINTER
Definition: sqltypes.h:68
RDBC_EXPORT SQLRETURN SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER StringLength)
Set an attribute of the SQL API connection.
#define SQL_ERROR
SQL API Return Code.
Definition: sql.h:51
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:59
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.
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:81
Header for RaimaDB ODBC types.
@ sOKAY
Definition: rdmretcodetypes.h:100
#define SQL_DRIVER_NOPROMPT
Definition: sqlext.h:1733
#define SQL_NTS
Definition: sql.h:63
RDBC_EXPORT SQLRETURN SQLDriverConnect(SQLHDBC ConnectionHandle, SQLHWND WindowHandle, const SQLCHAR *InConnectionString, SQLSMALLINT StringLength1, SQLCHAR *OutConnectionString, SQLSMALLINT BufferLength, SQLSMALLINT *StringLength2Ptr, SQLUSMALLINT DriverCompletion)
Driver Connect.
RDBC_EXPORT SQLRETURN SQLDisconnect(SQLHDBC ConnectionHandle)
Closes the connection associated with a specific connection handle.
int16_t SQLSMALLINT
Definition: sqltypes.h:57
#define SQL_SUCCEEDED(rc)
Definition: sql.h:57
enum RDM_RETCODE_E RDM_RETCODE
RaimaDB status and error return codes.
#define SQL_HANDLE_DBC
Definition: sql.h:82
#define SQL_SUCCESS
SQL API Return Code.
Definition: sql.h:42
RDBC_EXPORT SQLRETURN SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
Frees resources associated with a specific environment, connection, statement, or descriptor handle.
struct RDM_TFS_S * RDM_TFS
RaimaDB 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:69
RDM_RETCODE rdm_tfsInitialize(RDM_TFS tfs)
Initialize a RDM_TFS instance.