SQL Relay C++ API
|
00001 // Copyright (c) 1999-2001 David Muse 00002 // See the file COPYING for more information. 00003 00004 #ifndef SQLRCLIENT_H 00005 #define SQLRCLIENT_H 00006 00007 #include <sqlrelay/private/sqlrincludes.h> 00008 00009 #ifdef RUDIMENTS_NAMESPACE 00010 using namespace rudiments; 00011 #endif 00012 00013 class sqlrconnection { 00014 public: 00030 sqlrconnection(const char *server, uint16_t port, 00031 const char *socket, 00032 const char *user, const char *password, 00033 int32_t retrytime, int32_t tries); 00034 00035 00038 ~sqlrconnection(); 00039 00040 00041 00045 void setTimeout(int32_t timeoutsec, int32_t timeoutusec); 00046 00048 void endSession(); 00049 00054 bool suspendSession(); 00055 00062 uint16_t getConnectionPort(); 00063 00070 const char *getConnectionSocket(); 00071 00075 bool resumeSession(uint16_t port, const char *socket); 00076 00077 00078 00081 bool ping(); 00082 00085 const char *identify(); 00086 00088 const char *dbVersion(); 00089 00091 const char *serverVersion(); 00092 00094 const char *clientVersion(); 00095 00098 const char *bindFormat(); 00099 00100 00101 00103 bool selectDatabase(const char *database); 00104 00106 const char *getCurrentDatabase(); 00107 00108 00109 00112 uint64_t getLastInsertId(); 00113 00114 00115 00118 bool autoCommitOn(); 00119 00122 bool autoCommitOff(); 00123 00124 00125 00128 bool commit(); 00129 00132 bool rollback(); 00133 00134 00135 00140 const char *errorMessage(); 00141 00142 00143 00149 void debugOn(); 00150 00152 void debugOff(); 00153 00156 bool getDebug(); 00157 00158 00159 00164 void debugPrintFunction(int (*printfunction) 00165 (const char *,...)); 00166 00167 #include <sqlrelay/private/sqlrconnection.h> 00168 }; 00169 00170 00171 class sqlrcursor { 00172 public: 00175 sqlrcursor(sqlrconnection *sqlrc); 00176 00179 ~sqlrcursor(); 00180 00181 00182 00186 void setResultSetBufferSize(uint64_t rows); 00187 00191 uint64_t getResultSetBufferSize(); 00192 00193 00194 00199 void dontGetColumnInfo(); 00200 00202 void getColumnInfo(); 00203 00204 00208 void mixedCaseColumnNames(); 00209 00211 void upperCaseColumnNames(); 00212 00214 void lowerCaseColumnNames(); 00215 00216 00217 00230 void cacheToFile(const char *filename); 00231 00237 void setCacheTtl(uint32_t ttl); 00238 00241 const char *getCacheFileName(); 00242 00244 void cacheOff(); 00245 00246 00247 00252 bool getDatabaseList(const char *wild); 00253 00257 bool getTableList(const char *wild); 00258 00263 bool getColumnList(const char *table, const char *wild); 00264 00265 00266 00268 bool sendQuery(const char *query); 00269 00273 bool sendQuery(const char *query, uint32_t length); 00274 00277 bool sendFileQuery(const char *path, const char *filename); 00278 00279 00280 00282 void prepareQuery(const char *query); 00283 00287 void prepareQuery(const char *query, uint32_t length); 00288 00292 bool prepareFileQuery(const char *path, 00293 const char *filename); 00294 00295 00296 00298 void substitution(const char *variable, const char *value); 00299 00301 void substitution(const char *variable, int64_t value); 00302 00304 void substitution(const char *variable, double value, 00305 uint32_t precision, 00306 uint32_t scale); 00307 00309 void substitutions(const char **variables, 00310 const char **values); 00311 00313 void substitutions(const char **variables, 00314 const int64_t *values); 00315 00317 void substitutions(const char **variables, 00318 const double *values, 00319 const uint32_t *precisions, 00320 const uint32_t *scales); 00321 00322 00323 00325 void inputBind(const char *variable, const char *value); 00326 00328 void inputBind(const char *variable, const char *value, 00329 uint32_t valuelength); 00330 00332 void inputBind(const char *variable, int64_t value); 00333 00339 void inputBind(const char *variable, double value, 00340 uint32_t precision, 00341 uint32_t scale); 00342 00344 void inputBindBlob(const char *variable, 00345 const char *value, 00346 uint32_t size); 00347 00349 void inputBindClob(const char *variable, 00350 const char *value, 00351 uint32_t size); 00352 00354 void inputBinds(const char **variables, const char **values); 00355 00357 void inputBinds(const char **variables, 00358 const int64_t *values); 00359 00361 void inputBinds(const char **variables, 00362 const double *values, 00363 const uint32_t *precisions, 00364 const uint32_t *scales); 00365 00366 00367 00371 void defineOutputBindString(const char *variable, 00372 uint32_t bufferlength); 00373 00375 void defineOutputBindInteger(const char *variable); 00376 00378 void defineOutputBindDouble(const char *variable); 00379 00381 void defineOutputBindBlob(const char *variable); 00382 00384 void defineOutputBindClob(const char *variable); 00385 00387 void defineOutputBindCursor(const char *variable); 00388 00389 00390 00392 void clearBinds(); 00393 00397 uint16_t countBindVariables() const; 00398 00405 void validateBinds(); 00406 00409 bool validBind(const char *variable); 00410 00411 00412 00415 bool executeQuery(); 00416 00419 bool fetchFromBindCursor(); 00420 00421 00422 00425 const char *getOutputBindString(const char *variable); 00426 00429 int64_t getOutputBindInteger(const char *variable); 00430 00433 double getOutputBindDouble(const char *variable); 00434 00437 const char *getOutputBindBlob(const char *variable); 00438 00441 const char *getOutputBindClob(const char *variable); 00442 00445 uint32_t getOutputBindLength(const char *variable); 00446 00449 sqlrcursor *getOutputBindCursor(const char *variable); 00450 00451 00452 00455 bool openCachedResultSet(const char *filename); 00456 00457 00458 00461 uint32_t colCount(); 00462 00467 uint64_t rowCount(); 00468 00475 uint64_t totalRows(); 00476 00484 uint64_t affectedRows(); 00485 00489 uint64_t firstRowIndex(); 00490 00496 bool endOfResultSet(); 00497 00498 00499 00504 const char *errorMessage(); 00505 00506 00507 00511 void getNullsAsEmptyStrings(); 00512 00516 void getNullsAsNulls(); 00517 00518 00519 00521 const char *getField(uint64_t row, uint32_t col); 00522 00524 const char *getField(uint64_t row, const char *col); 00525 00527 int64_t getFieldAsInteger(uint64_t row, uint32_t col); 00528 00530 int64_t getFieldAsInteger(uint64_t row, const char *col); 00531 00533 double getFieldAsDouble(uint64_t row, uint32_t col); 00534 00536 double getFieldAsDouble(uint64_t row, const char *col); 00537 00538 00539 00541 uint32_t getFieldLength(uint64_t row, uint32_t col); 00542 00544 uint32_t getFieldLength(uint64_t row, const char *col); 00545 00546 00547 00550 const char * const *getRow(uint64_t row); 00551 00554 uint32_t *getRowLengths(uint64_t row); 00555 00558 const char * const *getColumnNames(); 00559 00561 const char *getColumnName(uint32_t col); 00562 00564 const char *getColumnType(uint32_t col); 00565 00567 const char *getColumnType(const char *col); 00568 00571 uint32_t getColumnLength(uint32_t col); 00572 00575 uint32_t getColumnLength(const char *col); 00576 00583 uint32_t getColumnPrecision(uint32_t col); 00584 00591 uint32_t getColumnPrecision(const char *col); 00592 00597 uint32_t getColumnScale(uint32_t col); 00598 00603 uint32_t getColumnScale(const char *col); 00604 00607 bool getColumnIsNullable(uint32_t col); 00608 00611 bool getColumnIsNullable(const char *col); 00612 00615 bool getColumnIsPrimaryKey(uint32_t col); 00616 00619 bool getColumnIsPrimaryKey(const char *col); 00620 00623 bool getColumnIsUnique(uint32_t col); 00624 00627 bool getColumnIsUnique(const char *col); 00628 00631 bool getColumnIsPartOfKey(uint32_t col); 00632 00635 bool getColumnIsPartOfKey(const char *col); 00636 00639 bool getColumnIsUnsigned(uint32_t col); 00640 00643 bool getColumnIsUnsigned(const char *col); 00644 00648 bool getColumnIsZeroFilled(uint32_t col); 00649 00653 bool getColumnIsZeroFilled(const char *col); 00654 00658 bool getColumnIsBinary(uint32_t col); 00659 00663 bool getColumnIsBinary(const char *col); 00664 00667 bool getColumnIsAutoIncrement(uint32_t col); 00668 00671 bool getColumnIsAutoIncrement(const char *col); 00672 00675 uint32_t getLongest(uint32_t col); 00676 00679 uint32_t getLongest(const char *col); 00680 00681 00682 00688 void suspendResultSet(); 00689 00696 uint16_t getResultSetId(); 00697 00701 bool resumeResultSet(uint16_t id); 00702 00707 bool resumeCachedResultSet(uint16_t id, 00708 const char *filename); 00709 00710 #include <sqlrelay/private/sqlrcursor.h> 00711 }; 00712 00713 #endif