00001 // 00002 // File: include/odbcpp/statement.h 00003 // Object: Define the statement object of the odbcpp library 00004 // Project: http://www.m2osw.com/odbcpp 00005 // Author: alexis_wilke@sourceforge.net 00006 // 00007 // Copyright (C) 2008 Made to Order Software Corp. 00008 // 00009 // This program is free software: you can redistribute it and/or modify 00010 // it under the terms of the GNU General Public License as published by 00011 // the Free Software Foundation, either version 3 of the License, or 00012 // (at your option) any later version. 00013 // 00014 // This program is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU General Public License 00020 // along with this program. If not, see <http://www.gnu.org/licenses/> 00021 // or <http://gpl3.m2osw.com/>. 00022 // 00023 #ifndef ODBCPP_STATEMENT 00024 #define ODBCPP_STATEMENT 00025 00026 #include "connection.h" 00027 00028 namespace odbcpp 00029 { 00030 00031 class record_base; 00032 00033 class statement : public handle 00034 { 00035 public: 00036 statement(connection& conn); 00037 00038 void set_attr(SQLINTEGER attr, SQLINTEGER integer); 00039 void set_attr(SQLINTEGER attr, SQLPOINTER ptr, SQLINTEGER length); 00040 void set_no_direct_fetch(bool no_direct_fetch = true); 00041 void execute(const std::string& order); 00042 void begin(); 00043 void commit(); 00044 void rollback(); 00045 void cancel(); 00046 void close_cursor(); 00047 SQLLEN cols() const; 00048 SQLLEN rows() const; 00049 bool fetch(record_base& rec, SQLSMALLINT orientation = SQL_FETCH_NEXT, SQLLEN offset = 0); 00050 00051 private: 00052 void has_data() const; 00053 00054 smartptr<connection> f_connection; 00055 bool f_has_data; 00056 bool f_no_direct_fetch; // if true, avoid SQLFetch(), use SQLFetchScroll() instead 00057 }; 00058 00059 00060 } // namespace odbcpp 00061 00062 #endif // #ifndef ODBCPP_STATEMENT