1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
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. *
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. *
15 ***************************************************************************/
16 #ifndef CACHETABLELOADER_H
17 #define CACHETABLELOADER_H
26 char indexName
[IDENTIFIER_LENGTH
];
27 FieldNameList fieldNameList
;
28 ~CacheIndexInfo() { fieldNameList
.removeAll(); }
31 class 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
);
50 strcpy(conditionVal
,"");
52 strcpy(fieldlistVal
,"");
58 DbRetVal
createIndex(SQLHSTMT hstmtmeta
, char *tableName
, HashIndexInitInfo
*inf
,AbsSqlStatement
*stmt
,bool isPKFieldSpecified
);
59 void setForceFlag(bool flag
){ shouldForce
= flag
;}
60 void setConnParam(char *user
, char *pass
){ strcpy(userName
, user
); strcpy(password
, pass
); }
61 void setTable(char *tablename
) { strcpy(tableName
,tablename
); }
62 void setCondition(char *condition
){strcpy(conditionVal
,condition
);} //new one
63 void setDsnName(char *dname
) {strcpy(dsnName
,dname
);}
65 //void setDsnId(char *dsnid) { strcpy(dsnId,dsnid); }
66 //void setDsnPwd(char *dsnpwd){ strcpy(dsnPwd,dsnpwd);}
67 void setFieldName(char *fldname
){ strcpy(fieldName
,fldname
);}
68 DbRetVal
addToCacheTableFile(bool isDirect
);
69 void setFieldListVal(char *field
) {strcpy(fieldlistVal
,field
);}
71 DbRetVal
addToCacheTableFile();
72 DbRetVal
removeFromCacheTableFile();
73 DbRetVal
load(bool tabDef
=true);
75 DbRetVal
unload(bool tabDefinition
= true);
77 DbRetVal
recoverAllCachedTables();
78 DbRetVal
load(AbsSqlConnection
*conn
, AbsSqlStatement
*stmt
, bool tabDef
);
79 DbRetVal
isTablePresent();// new one by :Jitendra
80 DbRetVal
CacheInfo(bool isTabPresent
);
81 DbRetVal
tablesOnDsn();
82 char *getConditionVal(char *condition
);
83 DbRetVal
checkingSchema(SQLHDBC hdbc
,SQLHSTMT hstmt
,AbsSqlConnection
*conn
, AbsSqlStatement
*stmt
,TDBInfo tdbName
);
84 DbRetVal
cacheAllTablesFromDs(char* tdbName
,bool tableDefinition
, bool isDirect
,char *username
,char *password
);
99 csql
= NULL
; targetdb
= NULL
; type
= typeUnknown
;
100 length
=0; nullData
= NULL
;
102 ~BindBuffer() { ::free(csql
); ::free(targetdb
); ::free(nullData
); }
107 char tableName
[IDENTIFIER_LENGTH
];
108 char fieldName
[IDENTIFIER_LENGTH
];
109 char projFieldlist
[IDENTIFIER_LENGTH
];
110 char condition
[IDENTIFIER_LENGTH
];
111 char dsnName
[IDENTIFIER_LENGTH
];
112 char pkField
[IDENTIFIER_LENGTH
];
114 //char dsnId[IDENTIFIER_LENGTH];
115 //char dsnPwd[IDENTIFIER_LENGTH];
117 void setTableName(char *tblName
){strcpy(tableName
,tblName
);}
118 void setDsnName(char *dsnname
) { strcpy(dsnName
,dsnname
); }
119 // void setDsnId(char *dsnid) { strcpy(dsnId,dsnid); }
120 //void setDsnPwd(char *dsnpwd){ strcpy(dsnPwd,dsnpwd);}
122 void setFieldName(char *fldName
){strcpy(fieldName
,fldName
);}
123 void setProjFieldList(char *fieldlist
){ strcpy(projFieldlist
,fieldlist
);}
124 void setCondition(char *cond
){ strcpy(condition
,cond
);}
125 void setPKField(char *pkfield
) { strcpy(pkField
, pkfield
); }
126 char *getTableName(){return tableName
;}
127 char *getFieldName(){return fieldName
;}
128 char *getPKFieldName(){return pkField
;}
129 char *getCondition(){ return condition
;}
130 char *getProjFieldList(){return projFieldlist
;}