Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Saving <strong>Objects</strong><br />
10.5 Saving <strong>Objects</strong><br />
You can save any persistent object using the following syntax:<br />
Do oref.%Save()<br />
where oref is the object reference of the object to save.<br />
The %Save method returns a status code which you can examine to determine the success<br />
or failure of the save:<br />
Set sc=oref.%Save()<br />
where sc is the status code returned by %Save and oref is the object reference of the object<br />
to save.<br />
The $$$ISOK macro returns 1 if the save was successful and 0 if it failed. Alternately, the<br />
$$$ISERR macro returns 1 if the save failed and 0 if the save was successful.<br />
If the save failed, the DisplayError^%apiOBJ call in the <strong>Caché</strong> Object Utility Library displays<br />
the text of the error message.<br />
The following syntax saves the object represented by oref and display any error messages if<br />
the save fails:<br />
Set sc = oref.%Save()<br />
If $$$ISERR(sc) {<br />
Do $System.Status.DisplayError(sc)<br />
}<br />
For example, the following code saves a Person object with OREFper and displays any errors<br />
occurring during the save:<br />
Set sc = per.%Save()<br />
If $$$ISERR(sc) {<br />
Do $System.Status.DisplayError(sc)<br />
}<br />
10.6 Deleting <strong>Objects</strong><br />
You can either delete a single object or all objects within an extent.<br />
<strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong> 81