Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Are occi statement objects persistent?

Re: Are occi statement objects persistent?

From: <lovecreatesbea..._at_gmail.com>
Date: 8 Dec 2006 21:39:13 -0800
Message-ID: <1165642753.631692.177410@j44g2000cwa.googlegroups.com>

Bruintje Beer wrote:
> "lovecreatesbea..._at_gmail.com" <lovecreatesbeauty_at_gmail.com> schreef in
> bericht news:1165589467.981282.198360_at_f1g2000cwa.googlegroups.com...
> >
> > KM wrote:
> >> 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.
> >
> > Thank you. When I tried to code like above, I got memory fault
> > (coredump). Maybe I didn't code it correctly.
> >

>

> You need to create an environment first
> Environment* env = Environment::createEnvironment(Environment::DEFAULT);
> Connection* con = env->createConection();

Thank you. That may be the problem I encountered. Perhaps the environment wasn't created in a proper time in my old code. My class inherited from another class, there was another class were responsible for creating the environment. I remember that when I moved createStatement(), terminateStatement() to Process() and removed the ctor and dctor in my class, the code worked. Received on Fri Dec 08 2006 - 23:39:13 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US