bbe*_*ard 1 xml select ibm-integration-bus extended-sql
我有一个看起来像这样的输入 xml
<log>
<line>
<id>1</id>
<line>
<id>2</id>
<otherLine>
<id>2</id>
<field>
12345-67
</field>
</otherLine>
</log>
Run Code Online (Sandbox Code Playgroud)
我在 esql 中所做的基本上是迭代每个<line>
元素,我想从值匹配的<otherLine>
地方检索<id>
值。
我有这样的代码:
declare inDoc reference to InputRoot.XMLNSC.log;
declare line reference to inDoc;
declare fieldValue character;
move line firstchild name 'line';
while lastmove(line) do
set fieldValue = select r.field from inDoc.otherLine[] as r where r.id = line.id;
-- I want this to be null when hitting the line with <id>1</id> and 12345-67 and hitting the line with <id>2</id>
move line nextsibling name 'line';
end while
Run Code Online (Sandbox Code Playgroud)
尝试部署代码时出现以下错误:
BIP2497E: (MyApp_flow.Main, <line number of select statement>) : Illegal data type for target. A list field reference is required.
The expression supplying the target must evaluate to a value of a suitable type. The given expression cannot possibly do so.
Correct the syntax of your ESQL expression in node 'MyApp_flow.Main', around line and column '<line number of the select statement>', then redeploy the message flow.
Run Code Online (Sandbox Code Playgroud)
我想知道在 esql 中完成此操作的正确方法是什么
谢谢
解决方案是在像这样的 select 语句中使用the
, item
, andfieldvalue
set fieldValue = the(select item fieldvalue(r.field) from inDoc.otherLine[] as r where r.id = line.id);
Run Code Online (Sandbox Code Playgroud)