1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
/**********************************************
* driverextras.h
*
* Purpose:
*
* To define driver specifc extras such as structs to be included
* along side the common ODBC includes.
*
* Description:
*
* The short-term storage a driver requires as infrastructure varies somewhat from
* DBMS to DBMS. The ODBC DriverManager requires predictable storage and it is defined
* in include files such as hstmt.h. The Driver also requires predictable storage and
* it is defined in driver.h. Storage *specific to a type of driver* is defined here.
*
* The three main storage items are the ENV, DBC, and STMT structs. These are defined
* as type void * in sql.h.
*
* So if your driver requires extra storage (and it probably does) then define
* the storage within these structs, allocate/initialize as required. Cast them
* to and from the standard names as required.
*
* For example;
*
* App DM |DRV
* (as per hdbc.h) |(as per driver.h)
*====================================================================
* hDbc=void* hDbc=SQLHDBC hDbc=HDBCEXTRAS
*--------------------------------------------------------------------
*
* DO NOT FORGET TO FREE ANY ALLOCATED MEMORY (at some point)
*
**********************************************************************
*
* This code was created by Peter Harvey (mostly during Christmas 98/99).
* This code is LGPL. Please ensure that this message remains in future
* distributions and uses of this code (thats about all I get out of it).
* - Peter Harvey pharvey@codebydesign.com
*
**********************************************************************/
#ifndef DRIVEREXTRAS_H
#define DRIVEREXTRAS_H
/**********************************************
* KEEP IT SIMPLE; PUT ALL DRIVER INCLUDES HERE THEN EACH DRIVER MODULE JUST INCLUDES THIS ONE FILE
**********************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <msql.h>
/**********************************************
* ENVIRONMENT: DRIVER SPECIFIC STUFF THAT NEEDS TO BE STORED IN THE DRIVERS ENVIRONMENT
**********************************************/
typedef struct tENVEXTRAS
{
int nDummy;
} ENVEXTRAS, *HENVEXTRAS;
/**********************************************
* CONNECTION: DRIVER SPECIFIC STUFF THAT NEEDS TO BE STORED IN THE DRIVERS CONNECTIONS
**********************************************/
typedef struct tDBCEXTRAS
{
int hServer; /* HANDLE TO mSQl SERVER (socket) */
} DBCEXTRAS, *HDBCEXTRAS;
/**********************************************
* STATEMENT: DRIVER SPECIFIC STUFF THAT NEEDS TO BE STORED IN THE DRIVERS STATEMENTS
**********************************************/
typedef struct tCOLUMNHDR /* this is how we will store bound columns */
{
/* EVERYTHING YOU WOULD EVER WANT TO KNOW ABOUT THE COLUMN. INIT THIS BY CALLING */
/* _NativeToSQLColumnHeader AS SOON AS YOU HAVE COLUMN INFO. THIS MAKES THE COL HDR LARGER */
/* BUT GENERALIZES MORE CODE. see SQLColAttribute() */
int bSQL_DESC_AUTO_UNIQUE_VALUE; /* IS AUTO INCREMENT COL? */
char *pszSQL_DESC_BASE_COLUMN_NAME; /* empty string if N/A */
char *pszSQL_DESC_BASE_TABLE_NAME; /* empty string if N/A */
int bSQL_DESC_CASE_SENSITIVE; /* IS CASE SENSITIVE COLUMN? */
char *pszSQL_DESC_CATALOG_NAME; /* empty string if N/A */
int nSQL_DESC_CONCISE_TYPE; /* ie SQL_CHAR, SQL_TYPE_TIME... */
int nSQL_DESC_DISPLAY_SIZE; /* max digits required to display */
int bSQL_DESC_FIXED_PREC_SCALE; /* has data source specific precision? */
char *pszSQL_DESC_LABEL; /* display label, col name or empty string */
int nSQL_DESC_LENGTH; /* strlen or bin size */
char *pszSQL_DESC_LITERAL_PREFIX; /* empty string if N/A */
char *pszSQL_DESC_LITERAL_SUFFIX; /* empty string if N/A */
char *pszSQL_DESC_LOCAL_TYPE_NAME; /* empty string if N/A */
char *pszSQL_DESC_NAME; /* col alias, col name or empty string */
int nSQL_DESC_NULLABLE; /* SQL_NULLABLE, _NO_NULLS or _UNKNOWN */
int nSQL_DESC_NUM_PREC_RADIX; /* 2, 10, or if N/A... 0 */
int nSQL_DESC_OCTET_LENGTH; /* max size */
int nSQL_DESC_PRECISION; /* */
int nSQL_DESC_SCALE; /* */
char *pszSQL_DESC_SCHEMA_NAME; /* empty string if N/A */
int nSQL_DESC_SEARCHABLE; /* can be in a filter ie SQL_PRED_NONE... */
char *pszSQL_DESC_TABLE_NAME; /* empty string if N/A */
int nSQL_DESC_TYPE; /* SQL data type ie SQL_CHAR, SQL_INTEGER.. */
char *pszSQL_DESC_TYPE_NAME; /* DBMS data type ie VARCHAR, MONEY... */
int nSQL_DESC_UNNAMED; /* qualifier for SQL_DESC_NAME ie SQL_NAMED */
int bSQL_DESC_UNSIGNED; /* if signed FALSE else TRUE */
int nSQL_DESC_UPDATABLE; /* ie SQL_ATTR_READONLY, SQL_ATTR_WRITE... */
/* BINDING INFO */
short nTargetType; /* BIND: C DATA TYPE ie SQL_C_CHAR */
char *pTargetValue; /* BIND: POINTER FROM APPLICATION TO COPY TO*/
long nTargetValueMax; /* BIND: MAX SPACE IN pTargetValue */
long *pnLengthOrIndicator; /* BIND: TO RETURN LENGTH OR NULL INDICATOR */
} COLUMNHDR;
typedef struct tSTMTEXTRAS
{
char **aResults; /* nRows x nCols OF CHAR POINTERS. Row 0= ptrs to COLUMNHDR. Col 0=Bookmarks */
int nCols; /* # OF VALID COLUMNS IN aColumns */
int nRows; /* # OF ROWS IN aResults */
int nRow; /* CURRENT ROW */
} STMTEXTRAS, *HSTMTEXTRAS;
/****************************
*
***************************/
SQLRETURN _GetData( SQLHSTMT hDrvStmt,
SQLUSMALLINT nCol,
SQLSMALLINT nTargetType,
SQLPOINTER pTarget,
SQLINTEGER nTargetLength,
SQLINTEGER *pnLengthOrIndicator );
SQLRETURN _NativeToSQLColumnHeader( COLUMNHDR *pColumnHeader,
void *pNativeColumnHeader );
int _NativeToSQLType( void *pNativeColumnHeader );
char *_NativeTypeDesc( char *pszTypeName,
int nType );
int _NativeTypeLength( void *pNativeColumnHeader );
int _NativeTypePrecision( void *pNativeColumnHeader );
#endif
|