Page 1 of 1

Create/Delete a TOraObject in C++

Posted: Thu 19 Mar 2015 16:32
by Morelli
Hi Folks,

I'm using C++ and not Delphi.
And i get a bit confused about what is the correct manner to create and destroy a TOraObject for example.

If I create an TOraObject with new. I get a pointer to a object-instance.
But do I have to call TOraObject->AllocObject (...) too? If yes, why?

And do I have to call TOraObject->FreeObject() or just delete?

So far I used to do it like this:

Code: Select all

TOraObject* sdoGeometry = new TOraObject (0);
sdoGeometry->AllocObject (query->Session->OCISvcCtx, "MDSYS.SDO_GEOMETRY");
...
sdoGeometry->FreeObject (true);
delete sdoGeometry;
Is this correct in C++?

Thanks for your help!

Re: Create/Delete a TOraObject in C++

Posted: Fri 20 Mar 2015 09:13
by AlexP
Hello,

After calling the Create method, you should also call the AllocObject method, in which the OCIObjectNew Api function will be called. To destroy an object, use the the Free method.

Re: Create/Delete a TOraObject in C++

Posted: Mon 23 Mar 2015 14:08
by Morelli
Hi,

What "Create" and "Free" Method do you mean? These functions do not exist in C++!
Do you mean CreateObject and FreeObject?

In your ODAC-Help there is a note (TOraObject.CreateObject Method):
Note: This method is obsolete, so it's better to use the AllocObject method instead.
And you say:
After calling the Create method, you should also call the AllocObject method
So what is correct now? Please explain ;)

And what I really not understand is why do I have to call c++ new and AllocObject?

Re: Create/Delete a TOraObject in C++

Posted: Tue 24 Mar 2015 08:48
by AlexP
The Create method means call of constructorю For С++ Builder, it is call of the New method. After creating an object, you should call the AllocObject method.