1 // 2 // PostgreSQLStatementImpl.h 3 // 4 // Library: Data/PostgreSQL 5 // Package: PostgreSQL 6 // Module: PostgreSQLStatementImpl 7 // 8 // Definition of the PostgreSQLStatementImpl class. 9 // 10 // Copyright (c) 2015, Applied Informatics Software Engineering GmbH. 11 // and Contributors. 12 // 13 // SPDX-License-Identifier: BSL-1.0 14 // 15 16 17 #ifndef SQL_PostgreSQL_PostgreSQLStatementImpl_INCLUDED 18 #define SQL_PostgreSQL_PostgreSQLStatementImpl_INCLUDED 19 20 21 #include "Poco/Data/PostgreSQL/PostgreSQL.h" 22 #include "Poco/Data/PostgreSQL/SessionImpl.h" 23 #include "Poco/Data/PostgreSQL/Binder.h" 24 #include "Poco/Data/PostgreSQL/Extractor.h" 25 #include "Poco/Data/PostgreSQL/StatementExecutor.h" 26 #include "Poco/Data/StatementImpl.h" 27 #include "Poco/SharedPtr.h" 28 #include "Poco/Format.h" 29 30 31 namespace Poco { 32 namespace Data { 33 namespace PostgreSQL { 34 35 36 class PostgreSQL_API PostgreSQLStatementImpl: public Poco::Data::StatementImpl 37 /// Implements statement functionality needed for PostgreSQL 38 { 39 public: 40 PostgreSQLStatementImpl(SessionImpl& aSessionImpl); 41 /// Creates the PostgreSQLStatementImpl. 42 43 ~PostgreSQLStatementImpl(); 44 /// Destroys the PostgreSQLStatementImpl. 45 46 protected: 47 virtual std::size_t columnsReturned() const; 48 /// Returns number of columns returned by query. 49 50 virtual int affectedRowCount() const; 51 /// Returns the number of affected rows. 52 /// Used to find out the number of rows affected by insert, delete or update. 53 54 virtual const MetaColumn& metaColumn(std::size_t aPosition) const; 55 /// Returns column meta data. 56 57 virtual bool hasNext(); 58 /// Returns true if a call to next() will return data. 59 60 virtual std::size_t next(); 61 /// Retrieves the next row from the resultset. 62 /// Will throw, if the resultset is empty. 63 64 virtual bool canBind() const; 65 /// Returns true if a valid statement is set and we can bind. 66 67 virtual bool canCompile() const; 68 /// Returns true if another compile is possible. 69 70 virtual void compileImpl(); 71 /// Compiles the statement, doesn't bind yet 72 73 virtual void bindImpl(); 74 /// Binds parameters 75 76 virtual Poco::Data::AbstractExtractor::Ptr extractor(); 77 /// Returns the concrete extractor used by the statement. 78 79 virtual Poco::Data::AbstractBinder::Ptr binder(); 80 /// Returns the concrete binder used by the statement. 81 82 private: 83 enum NextState 84 { 85 NEXT_DONTKNOW, 86 NEXT_TRUE, 87 NEXT_FALSE 88 }; 89 90 StatementExecutor _statementExecutor; 91 Binder::Ptr _pBinder; 92 Extractor::Ptr _pExtractor; 93 NextState _hasNext; 94 }; 95 96 97 } } } // namespace Poco::Data::PostgreSQL 98 99 100 #endif // SQL_PostgreSQL_PostgreSQLStatementImpl_INCLUDED 101