SQL Relay C++ API
/home/dmuse/src/sqlrelay/src/api/c++/include/sqlrelay/sqlrclient.h
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 SQLRCLIENT_DLLSPEC 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 
00131                 bool    begin();
00132 
00135                 bool    commit();
00136 
00139                 bool    rollback();
00140 
00141 
00142 
00147                 const char      *errorMessage();
00148 
00153                 int64_t         errorNumber();
00154 
00155 
00156 
00162                 void    debugOn();
00163 
00165                 void    debugOff();
00166 
00169                 bool    getDebug();
00170 
00171 
00172 
00177                 void    debugPrintFunction(int (*printfunction)
00178                                                         (const char *,...));
00179 
00180         #include <sqlrelay/private/sqlrconnection.h>
00181 };
00182 
00183 
00184 class SQLRCLIENT_DLLSPEC sqlrcursor {
00185         public:
00188                         sqlrcursor(sqlrconnection *sqlrc);
00189 
00192                         ~sqlrcursor();
00193 
00194 
00195 
00199                 void    setResultSetBufferSize(uint64_t rows);
00200 
00204                 uint64_t        getResultSetBufferSize();
00205 
00206 
00207 
00212                 void    dontGetColumnInfo();
00213 
00215                 void    getColumnInfo();
00216 
00217 
00221                 void    mixedCaseColumnNames();
00222 
00224                 void    upperCaseColumnNames();
00225 
00227                 void    lowerCaseColumnNames();
00228 
00229 
00230 
00243                 void    cacheToFile(const char *filename);
00244 
00250                 void    setCacheTtl(uint32_t ttl);
00251 
00254                 const char      *getCacheFileName();
00255 
00257                 void    cacheOff();
00258 
00259 
00260 
00265                 bool    getDatabaseList(const char *wild);
00266 
00270                 bool    getTableList(const char *wild);
00271 
00276                 bool    getColumnList(const char *table, const char *wild);
00277 
00278 
00279 
00281                 bool    sendQuery(const char *query);
00282 
00286                 bool    sendQuery(const char *query, uint32_t length);
00287 
00290                 bool    sendFileQuery(const char *path, const char *filename); 
00291 
00292 
00293 
00295                 void    prepareQuery(const char *query);
00296 
00300                 void    prepareQuery(const char *query, uint32_t length);
00301 
00305                 bool    prepareFileQuery(const char *path,
00306                                                 const char *filename);
00307 
00308 
00309 
00311                 void    substitution(const char *variable, const char *value);
00312 
00314                 void    substitution(const char *variable, int64_t value);
00315 
00317                 void    substitution(const char *variable, double value, 
00318                                                         uint32_t precision, 
00319                                                         uint32_t scale);
00320 
00322                 void    substitutions(const char **variables,
00323                                                 const char **values);
00324 
00326                 void    substitutions(const char **variables,
00327                                                 const int64_t *values);
00328 
00330                 void    substitutions(const char **variables,
00331                                         const double *values,
00332                                         const uint32_t *precisions, 
00333                                         const uint32_t *scales);
00334 
00335 
00336 
00338                 void    inputBind(const char *variable, const char *value);
00339 
00341                 void    inputBind(const char *variable, const char *value,
00342                                                         uint32_t valuelength);
00343 
00345                 void    inputBind(const char *variable, int64_t value);
00346 
00352                 void    inputBind(const char *variable, double value, 
00353                                                         uint32_t precision, 
00354                                                         uint32_t scale);
00355 
00359                 void    inputBind(const char *variable,
00360                                 int16_t year, int16_t month, int16_t day,
00361                                 int16_t hour, int16_t minute, int16_t second,
00362                                 const char *tz);
00363 
00365                 void    inputBindBlob(const char *variable,
00366                                                 const char *value,
00367                                                 uint32_t size);
00368 
00370                 void    inputBindClob(const char *variable,
00371                                                 const char *value,
00372                                                 uint32_t size);
00373 
00375                 void    inputBinds(const char **variables, const char **values);
00376 
00378                 void    inputBinds(const char **variables,
00379                                         const int64_t *values);
00380 
00382                 void    inputBinds(const char **variables,
00383                                         const double *values, 
00384                                         const uint32_t *precisions, 
00385                                         const uint32_t *scales);
00386 
00387 
00388 
00392                 void    defineOutputBindString(const char *variable,
00393                                                 uint32_t bufferlength);
00394 
00396                 void    defineOutputBindInteger(const char *variable);
00397 
00399                 void    defineOutputBindDouble(const char *variable);
00400 
00402                 void    defineOutputBindDate(const char *variable);
00403 
00405                 void    defineOutputBindBlob(const char *variable);
00406 
00408                 void    defineOutputBindClob(const char *variable);
00409 
00411                 void    defineOutputBindCursor(const char *variable);
00412 
00413 
00414 
00416                 void    clearBinds();
00417 
00421                 uint16_t        countBindVariables() const;
00422 
00429                 void    validateBinds();
00430 
00433                 bool    validBind(const char *variable);
00434 
00435 
00436 
00439                 bool    executeQuery();
00440 
00443                 bool    fetchFromBindCursor();
00444 
00445 
00446 
00449                 const char      *getOutputBindString(const char *variable);
00450 
00453                 int64_t         getOutputBindInteger(const char *variable);
00454 
00457                 double          getOutputBindDouble(const char *variable);
00458 
00461                 bool            getOutputBindDate(const char *variable,
00462                                                         int16_t *year,
00463                                                         int16_t *month,
00464                                                         int16_t *day,
00465                                                         int16_t *hour,
00466                                                         int16_t *minute,
00467                                                         int16_t *second,
00468                                                         const char **tz);
00469 
00472                 const char      *getOutputBindBlob(const char *variable);
00473 
00476                 const char      *getOutputBindClob(const char *variable);
00477 
00480                 uint32_t        getOutputBindLength(const char *variable);
00481 
00484                 sqlrcursor      *getOutputBindCursor(const char *variable);
00485 
00486 
00487                 
00490                 bool            openCachedResultSet(const char *filename);
00491 
00492 
00493 
00496                 uint32_t        colCount();
00497 
00502                 uint64_t        rowCount();
00503 
00510                 uint64_t        totalRows();
00511 
00519                 uint64_t        affectedRows();
00520 
00524                 uint64_t        firstRowIndex();
00525 
00531                 bool            endOfResultSet();
00532                 
00533                 
00534 
00539                 const char      *errorMessage();
00540 
00545                 int64_t         errorNumber();
00546 
00547 
00548 
00552                 void    getNullsAsEmptyStrings();
00553 
00557                 void    getNullsAsNulls();
00558 
00559 
00560 
00562                 const char      *getField(uint64_t row, uint32_t col);
00563 
00565                 const char      *getField(uint64_t row, const char *col);
00566 
00568                 int64_t getFieldAsInteger(uint64_t row, uint32_t col);
00569 
00571                 int64_t getFieldAsInteger(uint64_t row, const char *col);
00572 
00574                 double  getFieldAsDouble(uint64_t row, uint32_t col);
00575 
00577                 double  getFieldAsDouble(uint64_t row, const char *col);
00578 
00579 
00580 
00582                 uint32_t        getFieldLength(uint64_t row, uint32_t col);
00583 
00585                 uint32_t        getFieldLength(uint64_t row, const char *col);
00586 
00587 
00588 
00591                 const char * const *getRow(uint64_t row);
00592 
00595                 uint32_t        *getRowLengths(uint64_t row);
00596 
00599                 const char * const *getColumnNames();
00600 
00602                 const char      *getColumnName(uint32_t col);
00603 
00605                 const char      *getColumnType(uint32_t col);
00606 
00608                 const char      *getColumnType(const char *col);
00609 
00612                 uint32_t        getColumnLength(uint32_t col);
00613 
00616                 uint32_t        getColumnLength(const char *col);
00617 
00624                 uint32_t        getColumnPrecision(uint32_t col);
00625 
00632                 uint32_t        getColumnPrecision(const char *col);
00633 
00638                 uint32_t        getColumnScale(uint32_t col);
00639 
00644                 uint32_t        getColumnScale(const char *col);
00645 
00648                 bool            getColumnIsNullable(uint32_t col);
00649 
00652                 bool            getColumnIsNullable(const char *col);
00653 
00656                 bool            getColumnIsPrimaryKey(uint32_t col);
00657 
00660                 bool            getColumnIsPrimaryKey(const char *col);
00661 
00664                 bool            getColumnIsUnique(uint32_t col);
00665 
00668                 bool            getColumnIsUnique(const char *col);
00669 
00672                 bool            getColumnIsPartOfKey(uint32_t col);
00673 
00676                 bool            getColumnIsPartOfKey(const char *col);
00677 
00680                 bool            getColumnIsUnsigned(uint32_t col);
00681 
00684                 bool            getColumnIsUnsigned(const char *col);
00685 
00689                 bool            getColumnIsZeroFilled(uint32_t col);
00690 
00694                 bool            getColumnIsZeroFilled(const char *col);
00695 
00699                 bool            getColumnIsBinary(uint32_t col);
00700 
00704                 bool            getColumnIsBinary(const char *col);
00705 
00708                 bool            getColumnIsAutoIncrement(uint32_t col);
00709 
00712                 bool            getColumnIsAutoIncrement(const char *col);
00713 
00716                 uint32_t        getLongest(uint32_t col);
00717 
00720                 uint32_t        getLongest(const char *col);
00721 
00722 
00723 
00729                 void    suspendResultSet();
00730 
00737                 uint16_t        getResultSetId();
00738 
00742                 bool    resumeResultSet(uint16_t id);
00743 
00748                 bool    resumeCachedResultSet(uint16_t id,
00749                                                 const char *filename);
00750 
00755                 void    closeResultSet();
00756 
00757         #include <sqlrelay/private/sqlrcursor.h>
00758 };
00759 
00760 #endif