第八十章 SQL函数 $LIST(二)
示例
在以下嵌入式 SQL 示例中,两个 WRITE 语句都返回“Red”,即列表中的第一个元素。第一个默认写入第一个元素,第二个写入第一个元素,因为位置参数设置为 1:
/// d ##class(PHA.TEST.SQLFunction).Li4()
ClassMethod Li4()
{
s a = $lb("Red", "Blue", "Green")
&sql(SELECT $LIST(:a), $LIST(:a,1)
INTO :b,:c )
if SQLCODE '= 0 {
w !,"Error code ",SQLCODE
} else {
w !,"The one-arg sublist is ",b
w !,"The two-arg sublist is ",c }
}
DHC-APP>d ##class(PHA.TEST.SQLFunction).Li4()
The one-arg sublist is Red
The two-arg sublist is Red
以下嵌入式 SQL 示例返回列表中的第二个元素“Blue”:
/// d ##class(PHA.TEST.SQLFunction).