InterSystems 常见问题系列
使用 ErrorList 查询 SYS.ApplicationError 类.
- 注 1: 在 %SYS 命名空间中运行.
- 注 2: 这是个非存储的utility, 所以我们用 %ResultSet 类而不用 %SQL.Statement.
执行命令的例子如下.
USER>set $namespace="%SYS" //equal to zn "%SYS"
%SYS>set rset=##class(%ResultSet).%New()
%SYS>set rset.ClassName="SYS.ApplicationError"
%SYS>set rset.QueryName="ErrorList"
// The first argument of the query is the namespace name, the second argument is the date (in MM/DD/YYYY format).
%SYS>do rset.Execute("USER","08/17/2020")
// To display the results on the screen, execute the %Display() method.
%SYS>do rset.%Display()
Error # Error message Time Process DisplayPID Username Code line
1 <DIVIDE> 02:43:10 2536 2536 irisowner
1 Rows(s) Affected
%SYS>do rset.Close()
ObjectScriptObjectScript
以下显示如何获得在浏览行时获取SELECT的列值The following shows how to get column values of a SELECT while navigating through rows.
使用Next()方法来移动到一行(如果行存在的话返回1)
获取一列的话使用 Get("column name"). 具体列名,请参考类文档里面的ErrorList 查询描述。
%SYS>do rset.Execute("USER","08/17/2020")
%SYS>while rset.Next() { write rset.Get("Error #"),"-",rset.Get("Error message"),"-",rset.Get("Time"),"-",rset.Get("Code line"),!}
1-<DIVIDE>-02:43:10-
ObjectScriptObjectScript
For terminal viewing, you can also use the ^%ER routine.
Execute the following while in the namespace you want to reference (the example is executed in the USER namespace).
The green bold underlined text indicates the input area.
USER>do ^%ER
For Date: ?L
Thu 09/17/2020 (T) 2 Errors
Mon 09/07/2020 (T-10) 3 Errors
Mon 08/31/2020 (T-17) 1 Error
Mon 08/24/2020 (T-24) 1 Error
For Date: 09/17/2020 17 Sep 2020 2 Errors
Error: ?L
1. " *a" at 9:05 am. $I=|TRM|:|13484 ($X=0 $Y=15)
$J=13484 $ZA=0 $ZB=$c(13) $ZS=262144 ($S=268271680)
2. "^%ETN" at 9:05 am. $I=|TRM|:|13484 ($X=0 $Y=17)
$J=13484 $ZA=0 $ZB=$c(13) $ZS=262144 ($S=268263368)
%ETN ;%STACK-related error log
Error: 1
1. " *a" at 9:05 am. $I=|TRM|:|13484 ($X=0 $Y=15)
$J=13484 $ZA=0 $ZB=$c(13) $ZS=262144 ($S=268271680)
Variable:
Error:
For Date:
USER>
日期: 错误发生的日期格式为 mm/dd/yyyy
错误: 明确错误编号.
看完之后,回车即可退出。