Esql如何使用select语句从输入xml中检索值

时间:2017-02-09 18:10:52

标签: 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>

我在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中实现此目的的正确方法是什么

由于

1 个答案:

答案 0 :(得分:1)

解决方案是在select语句中使用itemfieldvalueset fieldValue = the(select item fieldvalue(r.field) from inDoc.otherLine[] as r where r.id = line.id); ,如下所示

{{1}}