Create/Delete a TOraObject in C++

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Morelli
Posts: 15
Joined: Thu 19 Mar 2015 15:45

Create/Delete a TOraObject in C++

Post by Morelli » Thu 19 Mar 2015 16:32

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!

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Create/Delete a TOraObject in C++

Post by AlexP » Fri 20 Mar 2015 09:13

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.

Morelli
Posts: 15
Joined: Thu 19 Mar 2015 15:45

Re: Create/Delete a TOraObject in C++

Post by Morelli » Mon 23 Mar 2015 14:08

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?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Create/Delete a TOraObject in C++

Post by AlexP » Tue 24 Mar 2015 08:48

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.

Post Reply