src/odbc/odbcStmt.h

Go to the documentation of this file.
00001 
00002 // Class CSqlOdbcStmt
00003 // Description: Statement Handle manager. 
00004 
00005 #ifndef _ODBC_STMT_H_
00006 #define _ODBC_STMT_H_
00007 
00008 // State's of Statement Handle.
00009 typedef enum
00010 {
00011      S0,                // hstmt in unallocated state 
00012      S1,                // hstmt in allocated state    
00013      S2,                // prepared hstmt - no result set will be genarated
00014      S3,                // prepared hstmt - result set will be genarated
00015      S4,                // executed hstmt - no result set generated.   
00016      S5,                // executed hstmt - result set generated.   
00017      S6,                // cursor positioned with SQLFetch
00018      S7,                // cursor positioned with SQLExtendedFetch
00019      S8,                // Function needs data - SQLParamData not called
00020      S9,                // Function needs data - SQLPutData not called
00021      S10,               // Function needs data - SQLPutData called
00022      S11,               // Still Executing
00023      S12                // Asyncronous cancel
00024  } StmtState_t ;
00025 
00026 class CSqlOdbcStmt
00027 {
00028         CSqlOdbcStmt( void ); // Should not create obj without using SQLAllocHandle
00029 
00030     public:
00031         // Top 2 variable declaration should not be moved down.
00032         int handleType_;            // Handle type.
00033         CSqlOdbcError err_;          // Last error info.
00034 
00035         CSqlOdbcDbc *parentDbc_;     // Parent Connection Handle.
00036         StmtState_t state_; 
00037         SQLCHAR cursorName_[ SQL_MAX_CURSOR_NAME_LEN ];
00038         int rowsAffected_;
00039         bool isPrepared_;
00040 
00041         SQLUINTEGER fetchMode_; // SQL_FETCH_SINGLE_TUPLE or SQL_FETCH_MULTIPLE_TUPLES
00042 
00043         // Descriptor Lists
00044         bool isParamBound_;
00045         CSqlOdbcDescList ard_;     // Application Row Descriptor
00046                                   // Bound columns using SQLBindCol()
00047 
00048         CSqlOdbcDescList ird_;     // Implimentation Row Descriptor
00049                                   // populated during SQLPrepare()
00050 
00051         CSqlOdbcDescList apd_;     // Application Parameter Descriptor
00052                                   // Bound paramenters using SQLBindParameter()
00053 
00054         CSqlOdbcDescList ipd_;     // Implimentation Parameter Descriptor
00055                                   // populated during SQLPrepare()
00056 
00057         AbsSqlStatement *fsqlStmt_; // CSQL
00058 
00059         // Statement Attributes
00060         
00061     // METHODS
00062 
00063         // State Transition
00064         SQLRETURN chkStateForSQLFreeHandle( void );
00065         SQLRETURN chkStateForSQLFreeStmt( void );
00066         SQLRETURN chkStateForSQLBindCol( void );
00067         SQLRETURN chkStateForSQLBindParameter( void );
00068 
00069         SQLRETURN chkStateForSQLPrepare( void );
00070         SQLRETURN chkStateForSQLExecute( void );
00071         SQLRETURN chkStateForSQLExecDirect( void );
00072         SQLRETURN chkStateForSQLFetch( void );
00073         SQLRETURN chkStateForSQLCloseCursor( void );
00074 
00075         SQLRETURN chkStateForSQLNumParams( void );
00076         SQLRETURN chkStateForSQLNumResultCols( void );
00077         SQLRETURN chkStateForSQLRowCount( void );
00078         SQLRETURN chkStateForSQLDescribeCol( void );
00079         SQLRETURN chkStateForSQLDescribeParam(void);
00080 
00081         SQLRETURN chkStateForSQLSetCursorName( void );
00082         SQLRETURN chkStateForSQLGetCursorName( void );
00083         
00084 
00085         // ODBC API's
00086         static SQLRETURN SQLAllocHandle(
00087             SQLHANDLE   inputHandle,    // IN
00088             SQLHANDLE   *outputHandle );// OUT
00089 
00090         static SQLRETURN SQLFreeHandle(
00091             SQLHANDLE inputHandle);     // IN
00092 
00093         SQLRETURN SQLFreeStmt(
00094             SQLUSMALLINT option);       // IN
00095 
00096         SQLRETURN SQLBindCol(
00097             SQLUSMALLINT columnNumber,  // IN
00098             SQLSMALLINT targetType,     // IN
00099             SQLPOINTER targetValue,     // OUT
00100             SQLINTEGER bufferLength,    // IN
00101             SQLINTEGER *ind); // IN_OUT
00102 
00103         SQLRETURN SQLBindParameter(
00104             SQLUSMALLINT parameterNumber,//IN
00105             SQLSMALLINT inputOutputType,// IN
00106             SQLSMALLINT valueType,      // IN
00107             SQLSMALLINT parameterType,  // IN
00108             SQLUINTEGER lengthPrecision,// IN
00109             SQLSMALLINT parameterScale, // IN
00110             SQLPOINTER parameterValue,  // OUT
00111             SQLINTEGER bufferLength,    // IN
00112             SQLINTEGER *ind);           // IN_OUT
00113 
00114         SQLRETURN SQLPrepare(
00115             SQLCHAR *statementText,     // IN
00116             SQLINTEGER textLength);     // IN
00117 
00118         SQLRETURN SQLExecute( void );
00119 
00120         SQLRETURN SQLExecDirect(
00121            SQLCHAR *statementText,      // IN
00122            SQLINTEGER textLength);      // IN
00123 
00124         SQLRETURN SQLSetStmtAttr(
00125            SQLINTEGER Option,           //IN
00126            SQLPOINTER Value,            //IN
00127            SQLINTEGER stringLength);    //IN
00128 
00129         SQLRETURN SQLFetch();
00130         
00131         SQLRETURN SQLCloseCursor();
00132 
00133         SQLRETURN SQLSetCursorName(
00134             SQLCHAR *cursorName,        // IN
00135             SQLSMALLINT nameLength);    // OUT
00136 
00137         SQLRETURN SQLGetCursorName(
00138             SQLCHAR *cursorName,        // OUT
00139             SQLSMALLINT bufferLength,   // IN
00140             SQLSMALLINT *nameLength);   // OUT
00141         
00142         SQLRETURN SQLNumResultCols(
00143             SQLSMALLINT *columnCount);  // OUT
00144 
00145         SQLRETURN SQLRowCount(
00146             SQLINTEGER *rowCount);      // OUT
00147 
00148         SQLRETURN SQLDescribeCol(
00149             SQLUSMALLINT columnNumber,  // IN 
00150             SQLCHAR      *columnName,   // OUT
00151             SQLSMALLINT  bufferLength,  // IN
00152             SQLSMALLINT  *nameLength,   // OUT
00153             SQLSMALLINT  *dataType,     // OUT
00154             SQLUINTEGER  *columnSize,   // OUT
00155             SQLSMALLINT  *decimalDigits,// OUT
00156             SQLSMALLINT  *nullable);    // OUT
00157 
00158         SQLRETURN  SQLColAttribute(
00159             SQLUSMALLINT columnNumber,      //IN
00160             SQLUSMALLINT fieldIdentifier,//IN
00161             SQLPOINTER   characterAttributePtr,//OUT
00162             SQLSMALLINT  bufferLength,       //IN
00163             SQLSMALLINT *stringLengthPtr, //OUT
00164             SQLPOINTER numericAttributePtr); //OUT
00165 
00166         SQLRETURN SQLNumParams(
00167                 SQLSMALLINT *     ParameterCountPtr); //OUT
00168 
00169         SQLRETURN SQLDescribeParam(
00170                 SQLUSMALLINT     paramNumber, //IN
00171                 SQLSMALLINT *     dataType,       //OUT
00172                 SQLUINTEGER *     paramSize,  //OUT
00173                 SQLSMALLINT *     decimalDigits,  //OUT
00174                 SQLSMALLINT *     isNullable);    //OUT
00175 
00176     // Other Methods
00177         void resetStmt( void );
00178 };
00179 
00180 #endif // _ODBC_STMT_H_

Generated on Mon Jun 9 22:37:15 2008 for csql by  doxygen 1.4.7