Setting a new TOracleObject

alan

Member
I want to set then insert an Oracle Object to my database. I'm able to set all the simple data type attributes of the object by calling the SetAttr() method. But I'm not able to set an embedded object attribute. I'm not able to acces it either.

TOracleObject *OPerson = new TOracleObject(OrclSession, "TOPERSON", "");
TOracleObject *OAddress = new TOracleObject OrclSession, "TOADDRESS", "");

OAddress = OPerson->ObjAttr("PERSONAL_ADDRESS");
In debug. mode it opens the page "Classes"
and stops the thread:
function ThreadProc(Thread: TThread): Integer;
var
FreeThread: Boolean;
begin
try
Thread.Execute;
finally
FreeThread := Thread.FFreeOnTerminate;
Result := Thread.FReturnValue;
Thread.FFinished := True;
Thread.DoTerminate;
if FreeThread then Thread.Free;
EndThread(Result);
end;
end;

How to set an embedded object attribute?

[This message has been edited by alan (edited 12 December 2000).]
 
What exactly do you do with the embedded object OAddress? What is the exception that occurs?

------------------
Marco Kalter
Allround Automations
 
The exception is "Access Violation". I haven't seen it before because of catching an EOracleError only. It's clear. The pointer to the embedded TOracleObject in a new TOracleObject is NULL.
Does enybody know how to set an embedded TOracleObject?
 
One thing I noticed in your code fragments is that you seem allocate an OAddress instance which you subsequently overwrite by the result of OPerson->ObjAttr.

Anyway, there are 2 ways to access the attributes of an embedded object:

1:
OAddress = OPerson->ObjAttr("personal_address");
OAddress->SetAttr("city", "new york");

2:
OPerson->SetAttr("personal_address.city", "new york");

Both work okay, and without any access violations (I did a quick test, just to be sure).

------------------
Marco Kalter
Allround Automations
 
Back
Top