2017-12-08 13 views
0

与えられた条件に基づいて2つのデータベーステーブルからの出力を結合する必要があります。 条件は次のとおりです。最初の表の列の値が2番目の表の列の値と同じ場合は、両方の表の行を1つに結合するか、行をスキップします。Mule - 与えられた条件に基づいて2つのDBテーブルの結果を結合する

私のコードは、何か以下のようになります。

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

<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 
    xmlns:spring="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd 
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd 
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd"> 
    <db:mysql-config name="MySQL_Configuration" host="xyz.com" port="3306" user="userXXX" password="****" database="bd" doc:name="MySQL Configuration"/> 
    <expression-filter expression="#[flowVars.payload1.seatsAvailable != flowVars.payload2.seatsAvailable]" name="Expression" doc:name="Expression"/> 
    <flow name="studyFlow"> 
     <poll doc:name="Poll"> 
      <fixed-frequency-scheduler frequency="1" timeUnit="HOURS"/> 
      <db:select config-ref="MySQL_Configuration" doc:name="Database"> 
       <db:parameterized-query><![CDATA[select * from table1]]></db:parameterized-query> 
      </db:select> 
     </poll> 
     <set-variable variableName="payload1" value="#[payload]" doc:name="resultFromTable1"/> 
     <db:select config-ref="MySQL_Configuration" doc:name="Database"> 
      <db:parameterized-query><![CDATA[select * from table2]]></db:parameterized-query> 
     </db:select> 
     <logger message="payload from american #[payload[0]]" level="INFO" doc:name="Logger"/> 
     <set-variable variableName="payload2" value="#[payload]" doc:name="resultFromTable2"/> 
     <dw:transform-message doc:name="Transform Message"> 
      <dw:set-payload><![CDATA[%dw 1.0 
%output application/java 
%var count = 0 
--- 
flowVars.payload1 map using (id = $.code2) { 

     (flowVars.payload2 filter ($.code2 contains id) map { 

      //col1:flowVars.payload2.code2, 
      col2: flowVars.payload1.toAirport 

    }) 
    } 
    ]]></dw:set-payload> 
     </dw:transform-message> 

     <logger message="#[payload]" level="INFO" doc:name="Logger"/> 
    </flow> 
</mule> 

しかし、これは私に適切な出力を与えるものではありません。助けてください。あなたはSQLクエリ自体を選択列に参加できないのはなぜ

答えて

0

..

以下のようなものがにtableAから選択し、tableA.id = tableB.id

は、あなたが任意の制約を持っていますTABLEB?

+0

うん、制約は、データソースが異なるホストから2つの異なるデータベースから得ることができるということです。 –

関連する問題