windows changes
[csql.git] / include / SqlOdbcStatement.h
blobe4f3e39f5adf4b67040c0ef8104bab6f72368f14
1 /***************************************************************************
2 * Copyright (C) 2007 by Prabakaran Thirumalai *
3 * praba_tuty@yahoo.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20 #ifndef SQLODBCSTATEMENT_H
21 #define SQLODBCSTATEMENT_H
22 #include <AbsSqlStatement.h>
23 #include <SqlOdbcConnection.h>
24 #include <SqlFactory.h>
25 #include <CSql.h>
26 class DllExport SqlOdbcStatement: public AbsSqlStatement
28 public:
29 SqlOdbcStatement()
31 innerStmt = NULL;
32 con = NULL;
33 tdbname = mysql;
34 isSelStmt = false;
35 len=NULL;
36 paramlen=NULL;
37 isPrepared = false;
38 strcpy(errState,"00000");
39 rowStatus = NULL;
40 nRecords = 0;
43 void setConnection(AbsSqlConnection *conn)
45 if (innerStmt) innerStmt->setConnection(conn->getInnerConnection());
46 con = conn;
49 DbRetVal executeDirect(char *stmt);
50 DbRetVal prepare(char *stmt);
51 DbRetVal prepareForResultSet(char *stmt);
53 DbRetVal execute(int &rowsAffect);
54 DbRetVal executeForResultSet();
55 DbRetVal bindParam(int pos, void*);
57 DbRetVal bindField(int pos, void* val);
58 DbRetVal rsBindField(int pos, void* val);
60 void* fetch();
61 void* fetch(DbRetVal &rv);
62 DbRetVal fetchScroll(void *nrows);
63 void setResultSetInfo(int nrecs);
64 void* fetchAndPrint(bool SQL);
65 void* next();
66 DbRetVal close();
67 int noOfProjFields();
69 void* getFieldValuePtr( int pos );
70 void* getFieldValuePtr( char *name );
72 DbRetVal free();
74 int noOfParamFields();
76 DbRetVal getProjFldInfo(int projPos, FieldInfo *&info);
78 DbRetVal getParamFldInfo(int paramPos, FieldInfo *&info);
80 void setShortParam(int paramPos, short value);
81 void setIntParam(int paramPos, int value);
82 void setLongParam(int paramPos, long value);
83 void setLongLongParam(int paramPos, long long value);
84 void setByteIntParam(int paramPos, ByteInt value);
85 void setFloatParam(int paramPos, float value);
86 void setDoubleParam(int paramPos, double value);
87 void setStringParam(int paramPos, char *value);
88 void setDateParam(int paramPos, Date value);
89 void setTimeParam(int paramPos, Time value);
90 void setTimeStampParam(int paramPos, TimeStamp value);
91 void setBinaryParam(int paramPos, void *value, int length);
92 bool isSelect();
93 void getPrimaryKeyFieldName(char *tablename, char *pkfieldname);
94 void setNullInfo(AbsSqlStatement *stmt);
95 // void setNullInfo(Table *stmt);
96 bool isFldNull(int pos);
97 bool isFldNull(char *name);
98 bool checkStmtType(char *stmtstr);
99 void setNull(int pos);
100 int getFldPos(char *name){ return 0;}
101 List getAllTableNames(DbRetVal &ret){ List dummy; return dummy;}
102 List getAllUserNames(DbRetVal &ret){ List dummy; return dummy;}
103 bool isTableExists(char *tblname);
104 int getNoOfPagesForTable(char *tbl){ return 0;}
105 DbRetVal loadRecords(char *tbl, void *buf){ return ErrBadCall;}
106 ResultSetPlan getResultSetPlan(){ return Normal;}
107 char *getTableName(){ return "";}
108 StatementType getStmtType() { return UnknownStatement; }
109 void setErrorState(SQLHSTMT hStmt);
110 DbRetVal resolveForBindField(SQLHSTMT hstmt);
111 DbRetVal resolveForResultSetBindField(SQLHSTMT hstmt);
112 void getProjFieldType(int *data);
113 TDBInfo getTdbInfo() { return tdbname; }
114 long long getLastInsertedVal(DbRetVal &rv) { rv = ErrBadCall; return 0;}
115 //TODO
117 SQLUSMALLINT *rowStatus;
118 private:
119 char errState[STATE_LENGTH];
120 TDBInfo tdbname;
121 bool isSelStmt;
122 bool isPrepared;
123 List paramList;
124 List bindList;
125 SQLHSTMT hstmt;
126 SQLINTEGER *len;
127 SQLINTEGER *paramlen;
128 int totalFld;
129 bool isProcedureCallStmt;
130 //For result set retrieval
131 int nRecords;
132 friend class SqlFactory;
135 #endif