Global 扫描和切片
这是一个在 IRIS 2020.1 和 Caché 2018.1.3 上工作的代码示例
不会与新版本保持同步
也不会获得 InterSystems 提供的支持服务!   
大多数情况下,默认存储使用的 global 只有 1 个表示 IDKEY 的下标级别。 对于索引 global,可能有 2 个或更多下标级别。 数组、父子关系或扩展了基础数据类的持久化类 是具有更多下标级别的示例。 但所有这些 global 都非常统一。 我们还能看到与类或表无关的 global,例如 ^SPOOL、^ERRORS 或 ^%SYS 其中的结构取决于各个级别的具有特殊含义的下标。 分析这些不一致的 global 是一个挑战,而只是把它的内容导出来不一定有助于理解依赖关系。 本示例的原理就像那个古老的笑话:“如何吃一头大象?” ==>“切成片吃!” 以下是实现的功能: 通过一条 SQL 语句,您可以逐级显示任意 global 的结构。 您提供 global 名称和要显示的最大级别,即可获得相关下标、节点的 $Data、后面的子节点数量以及在该级别存储的内容(如果有的话)。 示例:*\*SELECT \* FROM rcc\_G.scan where rcc\_G.Scan('^%SYS',1)=1**
Reference       Level $D SubN  Value
^%SYS               0   10 25    
("CSP")             1   10       
("CSPAppSec")       1   1       64
("CacheTempDir")    1   1      "c:\intersystems\iris\mgr\iristemp\"
("DBRefByName")     1   10       
("Ensemble")        1   11     "2020-04-25 18:37:18"
("ErrorPurge")      1   1      30
("FIPSMode")        1   1      0
("IRISTempDir")     1   1      "c:\intersystems\iris\mgr\iristemp\"
("JOURNAL")         1   11     0
("LANGUAGE")        1   10       
("LASTSESSIONGUID") 1   1     "EÊcRù¢GM£ô"_$c(127)_"¹9¾ÒÆ"
("LOCALE")          1   10       
("ModuleRoot")      1   10       
("NLS")             1   10       
("SERVICE")         1   10       
("SSPort")          1   1     51773
("StreamLocation")  1   10       
("SystemMode")      1   1     "TEST"
("TempDir")         1   1     "C:\InterSystems\IRIS\mgr\Temp"
("WebServer")       1   10       
("bindir")          1   1     "c:\intersystems\iris\bin\"
("shutdownlogerrors") 1 1 0
("sql")             1   10       
("sysdir")          1   1     "c:\intersystems\iris\mgr\"
("tercap")          1   10       
26 lines
*\*SELECT \* FROM rcc\_G.scan where rcc\_G.Scan('^%SYS',2)=1**
Reference                   Level $D SubN   Value
^%SYS                           0   10 25  
("CSP")                         1   10 1  
("CSP","LastUpdate")            2   1        "65553,44452"
("CSPAppSec")                   1   1  0     64
("CacheTempDir")                1   1  0     "c:\intersystems\iris\mgr\iristemp\"
("DBRefByName")                 1   10 9     
("DBRefByName","CACHE")         2   1        "^^c:\intersystems\iris\mgr\cache\"
("DBRefByName","CACHEUSER")     2   1        "^^c:\intersystems\user\"
("DBRefByName","ENSLIB")        2   1        "^^c:\intersystems\iris\mgr\enslib\"
("DBRefByName","IRISAUDIT")     2   1        "^^c:\intersystems\iris\mgr\irisaudit\"
("DBRefByName","IRISLIB")       2   1        "^^c:\intersystems\iris\mgr\irislib\"
("DBRefByName","IRISLOCALDATA") 2   1        "^^c:\intersystems\iris\mgr\irislocaldata\"
   < 60 lines more >
*\*SELECT \* FROM rcc\_G.scan where rcc\_G.Scan('^ERRORS',37)=1 and id['Jour'**
Reference                                            Level    $D  SubNodes    Value
(65588,1,"*STACK",1,"V","%00000","N","""JournalState""")    8   1    0         4
(65592,1,"*STACK",1,"V","%00000","N","""JournalState""")    8   1    0         4
(65592,2,"*STACK",1,"V","%00000","N","""JournalState""")    8   1    0         4