Using Caché Multi-Dimensional Storage - InterSystems ...
Using Caché Multi-Dimensional Storage - InterSystems ...
Using Caché Multi-Dimensional Storage - InterSystems ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Traversing Data within a Global<br />
Set ^Data(1) = ""<br />
Set ^Data(1,1) = ""<br />
Set ^Data(1,2) = ""<br />
Set ^Data(2) = ""<br />
Set ^Data(2,1) = ""<br />
Set ^Data(2,2) = ""<br />
Set ^Data(5,1,2) = ""<br />
To find the first, first-level subscript, we can use:<br />
SET key = $ORDER(^Data(""))<br />
This returns the first, first-level subscript following the null string (""). (The null string is<br />
used to represent the subscript value before the first entry; as a return value it is used to<br />
indicate that there are no following subscript values.) In this example, key will now contain<br />
the value 1.<br />
We can find the next, first-level subscript by using 1 or key in the $ORDER expression:<br />
SET key = $ORDER(^Data(key))<br />
If key has an initial value of 1, then this statement will set it to 2 (as ^Data(2) is the next firstlevel<br />
subscript). Executing this statement again will set key to 5 as that is the next first-level<br />
subscript. Note that 5 is returned even though there is no data stored directly at ^Data(5).<br />
Executing this statement one more time will set key to the null string (""), indicating that<br />
there are no more first level subscripts.<br />
By using additional subscripts with the $ORDER function, you can iterate over different<br />
subscript levels. $ORDER returns the next value of the last subscript in its argument list.<br />
<strong>Using</strong> the data above, the statement:<br />
SET key = $ORDER(^Data(1,""))<br />
will set key to 1 as ^Data(1,1) is the next second-level subscript. Executing this statement<br />
again will set key to 2 as that is the next second-level subscript. Executing this statement one<br />
more time will set key to “” indicating that there are no more second-level subscripts under<br />
node ^Data(1).<br />
3.5.1.1 Looping with $ORDER<br />
The following <strong>Caché</strong> ObjectScript code defines simple global and then loops over all of its<br />
first-level subscripts:<br />
<strong>Using</strong> <strong>Caché</strong> <strong>Multi</strong>-<strong>Dimensional</strong> <strong>Storage</strong> 21