Sql 在Mule中将日期参数传递给jdbc查询

Sql 在Mule中将日期参数传递给jdbc查询,sql,oracle,jdbc,mule,Sql,Oracle,Jdbc,Mule,我在Mule中有一个流,我想使用从一个查询中获得的日期参数作为另一个查询的输入 <jdbc:connector name="myConnector" transactionPerMessage="false" dataSource-ref="myDataSource"> <jdbc:query key="getPollTimes" value="SELECT to_char(last_poll_start, 'YYYY-MM-DD HH24:MI:SS') as las

我在Mule中有一个流,我想使用从一个查询中获得的日期参数作为另一个查询的输入

<jdbc:connector name="myConnector" transactionPerMessage="false" dataSource-ref="myDataSource">
    <jdbc:query key="getPollTimes" value="SELECT to_char(last_poll_start, 'YYYY-MM-DD HH24:MI:SS') as last_poll_start, to_char(last_poll_end, 'YYYY-MM-DD HH24:MI:SS') as last_poll_end FROM db_sources WHERE source_system = 'mySystem'" />
    <jdbc:query key="getCustomerIds" value="SELECT id FROM customers WHERE updated &lt; TO_DATE(#[variable:last_poll_end],'YYYY-MM-DD HH24:MI:SS')" />
</jdbc:connector>

<flow name="myFlow">
    <enricher>
        <jdbc:outbound-endpoint queryKey="getPollTimes" exchange-pattern="request-response" />
        <enrich target="#[variable:last_poll_end]" source="#[groovy:payload.last_poll_end]"/>
    </enricher>
    <logger level="INFO" message="last_poll_end = #[variable:last_poll_end]" />
    <jdbc:outbound-endpoint queryKey="getCustomerIds" exchange-pattern="request-response" />
</flow>
运行此程序时,我无法使其正常工作。请注意,我使用的是Oracle DB。我在下面列出了例外情况。有人遇到过这种情况吗

--------------------------------------------------------------------------------
Exception stack is:
1. Invalid column type(SQL Code: 17004, SQL State: + null) (java.sql.SQLException)
  oracle.jdbc.driver.DatabaseError:113 (null)
2. Invalid column type Query: SELECT ID FROM CUSTOMERS WHERE UPDATED < TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') Parameters: [[2000-01-01]](SQL Code: 17004, SQL State: + null) (java.sql.SQLException)
  org.apache.commons.dbutils.QueryRunner:540 (null)
3. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=jdbc://getCustomerIds, connector=JdbcConnector
{
  name=myConnector
  lifecycle=start
  this=668e94
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=false
  connected=true
  supportedProtocols=[jdbc]
  serviceOverrides=<none>
}
,  name='endpoint.jdbc.getCustomerIds', mep=REQUEST_RESPONSE, properties={queryTimeout=-1}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: ArrayList (org.mule.api.transport.DispatchException)
  org.mule.transport.AbstractMessageDispatcher:106 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------

问题解决了。部分原因是我从第一次查询中得到的日期变量被存储为数组。为了解决这个问题,我选择了第一个元素。此外,我在第二个sql查询中删除了截止日期

这将获取数组中的第一个元素:

<enrich target="#[variable:last_poll_end]" source="#[groovy:payload.last_poll_end[0]]"/>
更新的sql:

<jdbc:query key="getCustomerIds" value="SELECT id FROM customers WHERE updated &lt; #[variable:last_poll_end]" />

INFO 2012-01-03 08:27:00030[scheduler-TalentumESB_Worker-12]org.mule.api.processor.LoggerMessageProcessor:last_poll_end=[2000-01-01]这之后是我的原始帖子中的异常。记录器清楚地显示问题在选择部分,而不是插入部分。