12.07.2015 Views

Using Caché Globals - InterSystems Documentation

Using Caché Globals - InterSystems Documentation

Using Caché Globals - 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.

Sorting Data within <strong>Globals</strong>• Temporary globals are stored within the CACHETEMP database, which is always defined to bea local (that is, a non-network) database. All globals mapped to the CACHETEMP database aretreated as temporary globals.• Changes to temporary globals are not written to disk. Instead the changes are maintained withinthe in-memory buffer pool. A large temporary global may be written to disk if there is not sufficientspace for it within the buffer pool.• For maximum efficiency, changes to temporary globals are not logged to a journal file.• Temporary globals are automatically deleted whenever the <strong>Caché</strong> system is restarted. (Note: itcan be a very long time before a live system is restarted; so you should not count on this forcleaning up temporary globals.)By default, <strong>Caché</strong> defines any global whose name starts with “CacheTemp” as being a temporaryglobal. To avoid conflict with any temporary globals that <strong>Caché</strong> itself may use, you should start yourtemporary global names with “CacheTempUser” .<strong>Caché</strong> SQL uses temporary globals as scratch space for optimizing complex queries. It may also usestemporary globals as temporary indices during the execution of certain queries (for sorting, grouping,calculating aggregates, etc.)3.9 Sorting Data within <strong>Globals</strong>Data stored within globals is automatically sorted according to the value of the subscripts. For example,the following <strong>Caché</strong> ObjectScript code defines a set of globals (in random order) and then iterates overthem to demonstrate that the global nodes are automatically sorted by subscript:// Erase any existing dataKill ^Data// Define a set of global nodesSet ^Data("Cambridge") = ""Set ^Data("New York") = ""Set ^Data("Boston") = ""Set ^Data("London") = ""Set ^Data("Athens") = ""// Now iterate and display (in order)Set key = $Order(^Data(""))While (key '= "") {Write key,!Set key = $Order(^Data(key)) // next subscript}Applications can take advantage of the automatic sorting provided by globals to perform sort operationsor to maintain ordered, cross-referenced indices on certain values. <strong>Caché</strong> SQL and ObjectScript useglobals to perform such tasks automatically.<strong>Using</strong> <strong>Caché</strong> <strong>Globals</strong> 25

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

Saved successfully!

Ooh no, something went wrong!