Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Using</strong> <strong>Objects</strong> with <strong>Caché</strong> ObjectScript<br />
Set person.Name = "Doe,Jane"<br />
where person is the OREF of the Person object and “Doe,Jane” is the name you want to<br />
assign to that person.<br />
This general syntax works for any data type property. There is special syntax, described in<br />
the sections below, for:<br />
• reference properties<br />
• embedded object properties<br />
• collections–list properties and array properties<br />
• streams<br />
10.4.1 Modifying Reference Properties<br />
The data stored in a reference property exists as an independent object that can be instantiated<br />
separately from the object containing the reference. To establish the link between the two<br />
objects, the referenced object must be associated with the other object's reference property<br />
through a <strong>Caché</strong> ObjectScript call (see below). Once this link exists, you can either modify<br />
the referenced object directly or use cascading dot syntax.<br />
10.4.1.1 Associating an Object with a Reference Property<br />
There are two ways to associate an object with a reference property: if the object is in memory,<br />
you can use its OREF, or, if it exists on disk, you can use its object identifier (ID).<br />
For a referenced object in memory, the syntax is:<br />
Set oref.PropertyName = RefOref<br />
where oref is the OREF of the specific object, PropertyName is the name of the property to<br />
associate the data with, and RefOref is OREF of the referenced object. For example, to assign<br />
a particular Person object as the owner in a Car object, use the following code:<br />
Set car.Owner = person<br />
where car is the OREF of the Car object and person is the OREF of the Person object.<br />
If the referenced object has been stored to disk and has an ID value, you can use the following<br />
syntax:<br />
Do oref.PropertyNameSetObjectId(RefId)<br />
72 <strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong>