tfsrdbc/rdbcTfsAllocDefault.c
#include "sqlrtypes.h"
#include <stdio.h>
RDM_RETCODE exampleTfs_rdbcTfsAllocDefault (const char *databaseName)
{
RDM_TFS tfs;
SQLHENV hEnv;
SQLHDBC hDbc;
char connectStrIn[255];
char connectStrOut[255];
SQLSMALLINT outLen;
/* This creates a default 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:66
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: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 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: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.
RDBC_EXPORT SQLRETURN SQLDisconnect(SQLHDBC ConnectionHandle)
Closes the connection associated with a specific connection handle.
@ sOKAY
Definition: rdmretcodetypes.h:97
int16_t SQLSMALLINT
Definition: sqltypes.h:55
#define SQL_SUCCEEDED(rc)
Definition: sql.h:58
#define SQL_HANDLE_DBC
Definition: sql.h:83
#define SQL_SUCCESS
SQL API Return Code.
Definition: sql.h:43
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
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 status and error return codes.
Definition: rdmretcodetypes.h:43
RDM_RETCODE rdm_tfsInitialize(RDM_TFS tfs)
Initialize a RDM_TFS instance.