为什么这个简单的查询在骡子流中失败了?

时间:2016-06-22 12:30:40

标签: sql oracle mule mule-el anypoint-studio

我必须在现有的骡子流中做一些改变,知之甚少,虽然我花了几天阅读在线文档和可能的解决方案,但我无法弄清楚为什么这个查询失败,因为我也有更多的动态使用#[xxx]参数在我的流程中查询。查询如下:

select times from user_request where 
ip_address=SUBSTR(#message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS],2,INSTR(#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS], ':')-2) 
    and request_date=CAST(CURRENT_DATE as varchar2(8))

我得到的错误是:

  消息:索引:0   (java.lang.IndexOutOfBoundsException)。有效载荷:   {fecha_solicitud = 2016-06-22,moneda = USD,client_id = RIVERA,   user_ip = 127.0.0.1,request_times = 0}有效载荷类型:   java.util.LinkedHashMap元素:   / OANDAFlow / processors / 3 @ oanda:oanda.xml:126元素XML:       从user_requestwhere中选择时间   IP_ADDRESS = SUBSTR(#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS],2,INSTR(#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS]   ':') - 2)和request_date = CAST(CURRENT_DATE as   VARCHAR2(8))>   

注意:转换为日期的varchar是因为列request_date是varchar。

我直接在Oracle SQL开发人员中替换#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS]尝试了此查询 和/127.0.0.1:55406这样的例子并且工作正常,所以为什么通过骡子失败???

2 个答案:

答案 0 :(得分:3)

在第一个: #m essage.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS]您错过了 [

答案 1 :(得分:2)

您的查询中的某个字段需要字符串值尝试输入单引号..它可以正常工作,

试试这个 select times from user_request where ip_address=SUBSTR('#message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS]',2,'INSTR(#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS]', ':')-2) and request_date=CAST(CURRENT_DATE as varchar2(8))