25.01.2015 Views

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

change the second vaccination record associated with a Patient object using the following<br />

code:<br />

Do pat.Vaccination.SetAt(vac,2)<br />

where pat is the OREF of the Patient object and vac is the OREF of the new Vaccination<br />

object for slot 2.<br />

You can create a new object, populate it, then insert it into slotnusing the following syntax:<br />

Do oref.PropertyName.InsertAt(ItemOref,n)<br />

where oref is the OREF of the specific object to associate the data with,PropertyName is the<br />

name of the list property, and ItemOref is the OREF of the object. Again, insert a new list<br />

item increments the value of all previously-existing list items. For example, you can add a<br />

new vaccination record in the third slot of a Vaccination list of a Patient object using the<br />

following code:<br />

Do pat.Vaccination.InsertAt(vac,3)<br />

where pat is the OREF of the Patient object and vac is the OREF of the Vaccination object.<br />

10.4.3.3 Populating Lists of Persistent <strong>Objects</strong><br />

All of the syntax described for populating lists of embedded objects also applies for lists of<br />

persistent objects if the objects are in memory. In addition, you can populate lists of persistent<br />

objects with objects that are not in memory.<br />

You can populate a list of objects in several ways. You can add an object to the end of the<br />

list using the following syntax:<br />

Do oref.PropertyName.InsertObject(itemoid)<br />

where oref is the OREF of the specific object to associate the data with,PropertyName is the<br />

name of the list property, and itemoid is the OID of the object. For example, you can add a<br />

new dog to the list of pets owned by a person using the following code:<br />

Do per.Pets.InsertObject(DogOid)<br />

where per is the OREF of the Person object and DogOid is the OID of the Dog object.<br />

You can add an object to slot n using the following syntax:<br />

Do oref.PropertyName.SetObjectAt(ItemOid,n)<br />

Modifying <strong>Objects</strong><br />

where oref is the OREF of the specific object to associate the data with, PropertyName is the<br />

name of the list property, and ItemOid is the OID of the object. For example, you can change<br />

<strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong> 77

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!