views:

37

answers:

2

Hi

I have got the following code in a button on a form, but I want to get the OID or ID value of the saved object so that I can load it directly later.

procedure TFormMain.ButtonNewClick(Sender: TObject);
var
  Employee: Variant;
  OId: Variant;
begin
  Employee := Factory.New('Sample.Employee', True);
  if VarIsNull(Employee) or VarIsClear(Employee) then
  begin
    ShowMessage('Could not create Employee!');
    Exit;
  end;

  Employee.Name := 'Foo Bar';
  Employee.SSN := '616-27-7814';

  Employee.Sys_Save;

  OId := Employee.Sys_getOID; <- This doesn't exist

  Employee.Sys_Close;
  Employee := NULL;
end;

The documention shows functions like GetId but they require you to pass in the OID, but I don't see a function for that, and just .OID etc. don't work, I have the feeling since all the tutorials show examples of loading by OID or ID that I am missing something pretty basic.

Any pointers would be very helpful.

Thanks, Bruce

A: 

Reading the documentation for InterSystem Cache's ActiveX objects, I do not see any way to get an OID from a Sample.Employee object.

Remy Lebeau - TeamB
+1  A: 

Have you tried Employee.Oid or Employee.Sys_Oid?

Jens Mühlenhoff
I thought I had tried Sys_OID, which works, but OID and Sys_GetOID don't work which is what I tried before. I wish the documentation was better, but thanks very much.
Bruce
The documentation is actually better than it first seems. Goto http://docs.intersystems.com/cache20091/csp/documatic/%25CSP.Documatic.cls and have a look at the %Library package and the Persistent object. I guess you just have to prefix the mentioned members with Sys_ to call them from Delphi.
Jens Mühlenhoff