具有MEL表达式的SQL Update语句-Mule [英] SQL Update statement with MEL expression - Mule

查看:91
本文介绍了具有MEL表达式的SQL Update语句-Mule的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个SQL UPDATE语句,用于将特定记录更新到m子流中的数据库.我在将MEL表达式包含在语句中时遇到问题,并且我的流程中未执行SQL.

I have a SQL UPDATE statement, to update a particular record to the Database within a mule flow. I am having problems with including MEL expression within the statement and the SQL is not getting executed in my flow.

我正在尝试下一条命令:

I am trying the next command:

UPDATE CUSTOMERS SET STATUS=#[flowVars['TxnStatus']] WHERE REF_NUM=#[flowVars['ReferenceNumber']]

其中TxnStatusReferenceNumber是我的m子Flow中的流量变量.它看起来似乎很简单,但是记录没有更新.

where TxnStatus and ReferenceNumber are flow variables in my mule Flow. It looks seemingly simple, but the record is not updated.

当我使用MEL表达式尝试类似的SELECT语句时,它确实为我检索了值.请让我知道您的想法.

When I try a similar SELECT statement with MEL expressions it does retrieve the value for me. Please let me know your thoughts.

谢谢

添加的配置文件:

<?xml version="1.0" encoding="UTF-8"?>

   <jdbc-ee:mssql-data-source name="MuleDB_DataSource" user="${MuleDB_User}" password="${MuleDB_Password}" url="${MuleDB_URL}" transactionIsolation="UNSPECIFIED" doc:name="MS SQL Data Source"/>
    <jdbc-ee:connector name="Database" dataSource-ref="MuleDB_DataSource" validateConnections="true" queryTimeout="-1" pollingFrequency="10000" doc:name="Database" transactionPerMessage="false">
    </jdbc-ee:connector>
    <flow name="ExceptionFlowFlow1" doc:name="ExceptionFlowFlow1">
        <vm:inbound-endpoint exchange-pattern="one-way" path="Exception" doc:name="VM"/>
        <set-variable variableName="ExceptionPayload" value="#[payload]" doc:name="ExceptionPayload"/>
        <set-variable variableName="TxnStatus" value="Failure" doc:name="Variable"/>        
        <logger message="#[variable:TxnStatus]" level="INFO" category="Status" doc:name="Logger"/>
        <jdbc-ee:outbound-endpoint exchange-pattern="one-way" queryKey="Update_Status" queryTimeout="-1" connector-ref="Database" doc:name="Update_Status">
            <jdbc-ee:query key="Update_Status" value="UPDATE CUSTOMERS SET STATUS=#[flowVars['TxnStatus'] WHERE PAYMENT_REFERENCE_NUMBER=#[flowVars['TxnReference']"/>
         </jdbc-ee:outbound-endpoint>
        <logger message="#[payload]" level="INFO" doc:name="Logger"/>
        <catch-exception-strategy doc:name="Catch Exception Strategy">
            <logger message="#[exception]" level="INFO" category="ExceptionFlow failed with the exception --" doc:name="Logger"/>
        </catch-exception-strategy>
    </flow>
</mule>

推荐答案

在尝试将流变量用作SQL输入值时,我遇到了类似的问题.尝试像这样用#[variable:varName]替换#[flowVars['varName']]:

I've had similar issues when trying to use a flow variable as an SQL input value. Try replacing #[flowVars['varName']] with #[variable:varName] like so:

UPDATE CUSTOMERS SET STATUS=#[variable:TxnStatus] WHERE REF_NUM=#[variable:ReferenceNumber]

这对我有用.希望有帮助!

This has worked for me. Hope that helps!

这篇关于具有MEL表达式的SQL Update语句-Mule的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆