Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Are occi statement objects persistent?
lovecreatesbea..._at_gmail.com wrote:
> Can creating, using and terminating a member statement objects span
> multiple C++ functions in a class?
>
> Can I write code like the following?
>
> class COgFileSize{
>
> private:
> Connection *m_pConn;
> Statement *m_pStm;
>
> public:
> COgFileSize(){
> m_pStm = m_pConn->createStatement();
> }
>
> ~COgFileSize(){
> m_pStm = m_pConn->terminateStatement(m_pStm);
> }
>
> void Process(){
> m_pStm->setSQL("SELECT count(*) FROM dual;");
> ResultSet *rs = m_pStm->executeQuery();
> /* ... */
> }
> };
>
yes, you can. The memory is managed by OCCI and the control objects (Connection, Statement, Resultset) are deleted only by calling explicit terminate/close methods. You need to make sure the parent objects are around though. For example, the Env should not be terminated till all the connections from that Env are terminated. A Connection should not be terminated till all its Statement objects are terminated. A Statement should not be terminated till its ResultSet object is closed.
-KM. Received on Thu Dec 07 2006 - 21:53:04 CST