00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef RESOURCEPOOL_ORACLE_SQLSELECTROW_HH
00025 #define RESOURCEPOOL_ORACLE_SQLSELECTROW_HH
00026
00027 #include "mm/gc_ptr.hh"
00028
00029 #include "CommandCommon.hh"
00030 #include "ResourceFwd.hh"
00031
00032 #include "ResourcePool/SQL/BindOut.hh"
00033 #include "ResourcePool/SQL/SQLFetcher.hh"
00034 #include "ResourcePool/SQL/SQLSelect.hh"
00035
00036 #include "oracleRefTypeFwd.hh"
00037
00038 #include <string>
00039
00040 namespace fatalmind {
00041 namespace oracle {
00042
00043
00044 class SelectListMetaData;
00045 class SelectListBuffer;
00046 namespace internal {
00047
00048 class registerFinish;
00049 };
00050
00054 class oracleBindOut
00055 : public SQL::BindOut<oracleRefType, oracleRefTypeImpl>
00056 {
00057 public:
00058 using SQL::BindOut<oracleRefType, oracleRefTypeImpl>::NOTNULL;
00059 protected:
00060 ~oracleBindOut();
00061
00062 void _done();
00063 void _start();
00064 void real_bindout(oracleHandles&, const OCIStatementHandle&, const std::string&);
00065
00066 bool fetch(oracleHandles&, const OCIStatementHandle&, const std::string&);
00067 bool _fetch(oracleHandles&, const OCIStatementHandle&, const std::string&);
00068 void finish(oracleHandles&, const OCIStatementHandle&, const std::string&);
00069
00070 gc_ptr<SelectListMetaData> _slmd;
00071 gc_ptr<SelectListBuffer> _slb;
00072
00073 void validateBindOut(const std::string& SQL) const;
00074
00075 friend
00076 class SelectListBuffer;
00077 friend
00078 class internal::registerFinish;
00079 };
00080
00084 template<class TM, template<class> class SLMDC>
00085 class SQLSelectRow
00086 : public CommandCommon<TM, SLMDC>
00087 , public oracleBindOut
00088 , public fatalmind::SQLSelect
00089 {
00090 typedef CommandCommon<TM, SLMDC> super;
00091 protected:
00092 using super::_SQL;
00093 using super::_sth;
00094 public:
00095 using oracleBindOut::NOTNULL;
00096
00097 SQLSelectRow(const std::string& SQL, SQL::SQLFetcher& = SQL::NopFetcher);
00098 SQLSelectRow(const ResourcePool<ResourceType<TM> >& p, const std::string& SQL, SQL::SQLFetcher& = SQL::NopFetcher);
00099 virtual ~SQLSelectRow();
00100
00101 using super::execute;
00102
00103 protected:
00104 virtual Clone* DoClone() const;
00105 void _execute(oracleResource<TM>&, StatementCache&);
00106
00107 void postSelectBuffer(oracleHandlesWithCache<TM>&);
00108 bool preSelectBuffer(oracleHandlesWithCache<TM>&);
00109 void preSelectBufferBind(oracleHandles&);
00110 bool prepare_buffer(oracleHandlesWithCache<TM>& hand, StatementCache& sthcache);
00111
00112 virtual const std::string& getCommandName() const;
00113 static const std::string _SQLSelectRowName;
00114 };
00115
00116 namespace internal {
00117
00118 class registerFinish {
00119 public:
00120 registerFinish(oracleHandles& hand, oracleBindOut& cmd, const OCIStatementHandle& sth, const std::string& SQL)
00121 : _hand(hand)
00122 , _sth(sth)
00123 , _SQL(SQL)
00124 , _cmd(cmd)
00125 {
00126 }
00127 ~registerFinish() {
00128 _cmd.finish(_hand, _sth, _SQL);
00129 };
00130 private:
00131 oracleHandles& _hand;
00132 const OCIStatementHandle &_sth;
00133 const std::string& _SQL;
00134
00135 oracleBindOut& _cmd;
00136 };
00137
00138 }
00139 }
00140 }
00141 #endif