00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _SWORD_DB_DBQUERY_ODBC_
00020 #define _SWORD_DB_DBQUERY_ODBC_
00021
00022
00023 #ifdef HAVE_DB_ODBC
00024
00025 #include "sword/db.DbQuery.h"
00026 #include "sword/db.DbConnection_ODBC.h"
00027 #include <map>
00028
00029 namespace sword {
00030
00031 class SWORDDECL DbQuery_ODBC : public DbQuery {
00032 public:
00033 DbQuery_ODBC(DbConnection_ODBC* con, int timeout = 120);
00034 virtual ~DbQuery_ODBC();
00035
00036 virtual bool exec(const std::string& sql, bool reportWarningsAsErrors = true);
00037 virtual bool nextRow();
00038 virtual bool nextSet();
00039 virtual int columns();
00040
00041 virtual Variant get(word column);
00042 virtual Variant get(const std::string& column);
00043
00044 private:
00045 DbConnection_ODBC* con_;
00046 SQLHSTMT dbs_;
00047 int columns_;
00048
00049 typedef std::vector<Variant::Type> ColumnTypes;
00050 ColumnTypes columnTypes_;
00051 bool columnTypesReady_;
00052
00053 typedef std::vector<std::string> ColumnNames;
00054 ColumnNames columnNames_;
00055 typedef std::map<std::string, word> ColumnPositions;
00056 ColumnPositions columnPositions_;
00057
00058 typedef std::vector<Variant> RowData;
00059 RowData row_;
00060 bool rowReady_;
00061
00062 void reportError_(const std::string& message);
00063 bool firstRow_();
00064 bool nextSet_();
00065
00066 void fetchRow_();
00067 void fetchColumnTypes_();
00068
00069 word columnPosition_(const std::string& columnName);
00070 };
00071
00072 }
00073
00074 #endif // HAVE_DB_ODBC
00075
00076 #endif // _SWORD_DB_DBQUERY_ODBC_