12.07.2015 Views

Using Caché Globals - InterSystems Documentation

Using Caché Globals - InterSystems Documentation

Using Caché Globals - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Managing ConcurrencyTSTARTSet sc = object1.%Save()If ($$$ISOK(sc)) {// first save worked, do the secondSet sc = object2.%Save()}If ($$$ISERR(sc)) {// one of the saves failed, rollbackTROLLBACK}Else {// everything is ok, commitTCOMMIT}3.12 Managing ConcurrencyThe operation of setting or retrieving a single global node is atomic; it is guaranteed to always succeedwith consistent results. For operations on multiple nodes or for controlling transaction isolation (seethe section on Lock and Transactions), <strong>Caché</strong> provides the ability to acquire and release locks.Locks are managed by the <strong>Caché</strong> Lock Manager. Within <strong>Caché</strong> ObjectScript, you can directly acquireand release locks by means of the LOCK command. (<strong>Caché</strong> Objects and SQL automatically acquireand release locks as needed).For details on the LOCK command, refer to the LOCK command reference page.3.13 Checking the Most Recent GlobalReferenceThe most recent global reference is recorded in the <strong>Caché</strong> ObjectScript $ZREFERENCE specialvariable. $ZREFERENCE contains the most recent global reference, including subscripts and extendedglobal reference, if specified. Note that $ZREFERENCE indicates neither whether the global referencesucceeded, nor if the specified global exists. <strong>Caché</strong> simply records the most recently specified globalreference.3.13.1 Naked Global ReferenceFollowing a subscripted global reference, <strong>Caché</strong> sets a naked indicator to that global name and subscriptlevel. You can then make subsequent references to the same global and subscript level using a nakedglobal reference, omitting the global name and higher level subscripts. This streamlines repeated referencesto the same global at the same (or lower) subscript level.<strong>Using</strong> <strong>Caché</strong> <strong>Globals</strong> 31

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

Saved successfully!

Ooh no, something went wrong!