two IN clause in sql statement does not clear the value clause before
[csql.git] / include / CacheTableLoader.h
blobeb8b9a39741d833cddfcf420e4b8e089705e7785
1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.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 ***************************************************************************/
16 #ifndef CACHETABLELOADER_H
17 #define CACHETABLELOADER_H
18 #include <CSql.h>
19 #include <sql.h>
20 #include <sqlext.h>
21 #include <Network.h>
23 class DllExport CacheIndexInfo
25 public:
26 char indexName[IDENTIFIER_LENGTH];
27 FieldNameList fieldNameList;
28 ~CacheIndexInfo() { fieldNameList.removeAll(); }
31 class DllExport CacheTableLoader
33 char tableName[IDENTIFIER_LENGTH];
34 char fieldName[IDENTIFIER_LENGTH];
35 char userName[IDENTIFIER_LENGTH];
36 char password[IDENTIFIER_LENGTH];
37 char conditionVal[IDENTIFIER_LENGTH]; //added newly
38 char fieldlistVal[IDENTIFIER_LENGTH];
39 char dsnName[IDENTIFIER_LENGTH];
40 bool resolveForDSN(char *dsn, TDBInfo &tdbName, DbRetVal &rv);
41 void generateCacheTableStatement(char *stmtBuf);
42 bool prepareCreateIndexStatement(SQLHSTMT hstmtmeta, char *crtIdxStmt, TDBInfo tdbName, HashIndexInitInfo *inf);
43 DbRetVal prepareCreateTableStatement(char *crtTblStmt, SQLHSTMT hstmt, HashIndexInitInfo *inf, int totalFields, TDBInfo tdbName, bool &isKeyFld);
44 void prepareInsertStatement(AbsSqlStatement *stmt, List *fNameList, char *insStmt);
45 DbRetVal hasRecords(DatabaseManager *dbMgr,const char* tableName);
46 DbRetVal connect(void *&, void*&, void*&, char*, char*);
47 bool shouldForce;
48 public:
49 CacheTableLoader()
51 strcpy(tableName,"");
52 strcpy(conditionVal,"");
53 strcpy(fieldName,"");
54 strcpy(fieldlistVal,"");
55 strcpy(dsnName,"");
56 //strcpy(dsnId,"");
57 //strcpy(dsnPwd,"");
58 shouldForce = false;
60 DbRetVal createIndex(SQLHSTMT hstmtmeta, char *tableName, HashIndexInitInfo *inf,AbsSqlStatement *stmt,bool isPKFieldSpecified);
61 void setForceFlag(bool flag){ shouldForce = flag;}
62 void setConnParam(char *user, char *pass){ strcpy(userName, user); strcpy(password, pass); }
63 void setTable(char *tablename) { strcpy(tableName,tablename); }
64 void setCondition(char *condition){strcpy(conditionVal,condition);} //new one
65 void setDsnName(char *dname) {strcpy(dsnName,dname);}
67 //void setDsnId(char *dsnid) { strcpy(dsnId,dsnid); }
68 //void setDsnPwd(char *dsnpwd){ strcpy(dsnPwd,dsnpwd);}
69 void setFieldName(char *fldname){ strcpy(fieldName,fldname);}
70 DbRetVal addToCacheTableFile(bool isDirect);
71 void setFieldListVal(char *field) {strcpy(fieldlistVal,field);}
73 DbRetVal addToCacheTableFile();
74 DbRetVal removeFromCacheTableFile();
75 DbRetVal load(bool tabDef=true);
76 DbRetVal reload();
77 DbRetVal unload(bool tabDefinition = true);
78 DbRetVal refresh();
79 DbRetVal recoverAllCachedTables();
80 DbRetVal load(AbsSqlConnection *conn, AbsSqlStatement *stmt, bool tabDef);
81 DbRetVal isTablePresent();// new one by :Jitendra
82 DbRetVal CacheInfo(bool isTabPresent);
83 DbRetVal tablesOnDsn();
84 char *getConditionVal(char *condition);
85 DbRetVal checkingSchema(SQLHDBC hdbc,SQLHSTMT hstmt,AbsSqlConnection *conn, AbsSqlStatement *stmt,TDBInfo tdbName);
86 DbRetVal cacheAllTablesFromDs(char* tdbName,bool tableDefinition, bool isDirect,char *username,char *password);
91 class DllExport BindBuffer
93 public:
94 void *csql;
95 void *targetdb;
96 SQLLEN *nullData;
97 DataType type;
98 int length;
99 BindBuffer()
101 csql = NULL; targetdb = NULL; type = typeUnknown;
102 length =0; nullData = NULL;
104 ~BindBuffer() { ::free(csql); ::free(targetdb); ::free(nullData); }
106 class DllExport CacheTableInfo
108 public:
109 char tableName[IDENTIFIER_LENGTH];
110 char fieldName[IDENTIFIER_LENGTH];
111 char projFieldlist[IDENTIFIER_LENGTH];
112 char condition[IDENTIFIER_LENGTH];
113 char dsnName[IDENTIFIER_LENGTH];
114 char pkField[IDENTIFIER_LENGTH];
116 //char dsnId[IDENTIFIER_LENGTH];
117 //char dsnPwd[IDENTIFIER_LENGTH];
119 void setTableName(char *tblName){strcpy(tableName,tblName);}
120 void setDsnName(char *dsnname) { strcpy(dsnName,dsnname); }
121 // void setDsnId(char *dsnid) { strcpy(dsnId,dsnid); }
122 //void setDsnPwd(char *dsnpwd){ strcpy(dsnPwd,dsnpwd);}
124 void setFieldName(char *fldName){strcpy(fieldName,fldName);}
125 void setProjFieldList(char *fieldlist){ strcpy(projFieldlist,fieldlist);}
126 void setCondition(char *cond){ strcpy(condition,cond);}
127 void setPKField(char *pkfield) { strcpy(pkField, pkfield); }
128 char *getTableName(){return tableName;}
129 char *getFieldName(){return fieldName;}
130 char *getPKFieldName(){return pkField;}
131 char *getCondition(){ return condition;}
132 char *getProjFieldList(){return projFieldlist;}
134 #endif