14 * You should have received a copy of the GNU General Public License |
14 * You should have received a copy of the GNU General Public License |
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 */ |
16 */ |
17 #pragma once |
17 #pragma once |
18 |
18 |
|
19 #include <list> |
|
20 #include <string> |
|
21 #include <utility> |
|
22 |
19 #include <relpipe/reader/typedefs.h> |
23 #include <relpipe/reader/typedefs.h> |
20 #include <relpipe/reader/TypeId.h> |
24 #include <relpipe/reader/TypeId.h> |
21 #include <relpipe/writer/TypeId.h> |
25 #include <relpipe/writer/TypeId.h> |
22 #include "SqlException.h" |
26 #include "SqlException.h" |
|
27 #include "ResultSet.h" |
23 |
28 |
24 namespace relpipe { |
29 namespace relpipe { |
25 namespace tr { |
30 namespace tr { |
26 namespace sql { |
31 namespace sql { |
27 |
32 |
28 class PreparedStatement { |
33 class PreparedStatement { |
29 private: |
34 private: |
30 void* stmt; |
35 void* statement; |
|
36 std::wstring_convert<std::codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings |
|
37 std::list<relpipe::reader::boolean_t> booleanParameters; |
|
38 std::list<relpipe::reader::integer_t> integerParameters; |
|
39 std::list<std::pair<std::string, long>> stringParameters; |
31 public: |
40 public: |
32 PreparedStatement(void* stmt); |
41 PreparedStatement(void* stmt); |
33 virtual ~PreparedStatement(); |
42 virtual ~PreparedStatement(); |
34 void setBoolean(int parameterIndex, relpipe::reader::boolean_t value); |
43 ResultSet* executeQuery(); |
35 void setInteger(int parameterIndex, relpipe::reader::integer_t value); |
44 long executeUpdate(); |
36 void setString(int parameterIndex, std::string value); |
|
37 void setNull(int parameterIndex); |
|
38 bool next(); |
|
39 void reset(); |
45 void reset(); |
40 int getColumnCount(); |
46 void setBoolean(int parameterNumber, relpipe::reader::boolean_t value); |
41 std::string getColumName(int columnIndex); |
47 void setInteger(int parameterNumber, relpipe::reader::integer_t value); |
42 relpipe::writer::TypeId getColumType(int columnIndex, relpipe::writer::TypeId defaultType = relpipe::writer::TypeId::STRING); |
48 void setString(int parameterNumber, relpipe::reader::string_t value); |
43 std::string getString(int columnIndex); |
49 void setNull(int parameterNumber); |
44 }; |
50 }; |
45 |
51 |
46 } |
52 } |
47 } |
53 } |
48 } |
54 } |