1

我有一个看起来像这样的输入 xml

<log>
    <line>
        <id>1</id>
    <line>
        <id>2</id>
    <otherLine>
        <id>2</id>
        <field>
            12345-67
        </field>
    </otherLine>
</log>

我在 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

尝试部署代码时出现以下错误:

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.

我想知道在 esql 中完成此任务的正确方法是什么

谢谢

4

1 回答 1

6

解决方案是在这样的 select 语句中使用the, item, 和fieldvalue

set fieldValue = the(select item fieldvalue(r.field) from inDoc.otherLine[] as r where r.id = line.id);
于 2017-02-09T20:31:59.257 回答