camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Wulff <owu...@talend.com>
Subject RE: delete records of db table before importing from csv
Date Fri, 16 Nov 2012 21:18:38 GMT
Thanks Christian. Works like a charm :-)

Oli
________________________________________
From: Christian Müller [christian.mueller@gmail.com]
Sent: 15 November 2012 22:13
To: users@camel.apache.org
Subject: Re: delete records of db table before importing from csv

Something like this:

<route id="myimport">
  <from uri="file:src/data/import/?charset=iso-8859-1" />
  <multicast stopOnException="true">
    <to uri="direct:trunkateTable"/>
    <to uri="direct:insertUsers"/>
  </multicast>
</route>

<route id="trunkateTable">
  <from uri="direct:trunkateTable" />
  <to uri="sql:DROP TABLE USER?dataSourceRef=myDS" />
</route>

<route id="insertUsers">
  <from uri="direct:insertUsers" />
  <split streaming="true" parallelProcessing="true">
    <tokenize token="\n" />
    <unmarshal>
      <csv delimiter=";" />
    </unmarshal>
      <setBody><simple>${in.body[0]}</simple></setBody>
      <to uri="sql:INSERT INTO USER (USER, FIRSTNAME, LASTNAME, LOCATION)
VALUES (#, #, #, #)?dataSourceRef=myDS" />
  </split>
</route>

Best,
Christian

On Thu, Nov 15, 2012 at 1:11 PM, Oliver Wulff <owulff@talend.com> wrote:

> Hi there
>
> I've defined a camel route which imports data from a csv file into a
> table. Before that, the content of the db table must be deleted. The import
> works fine but I don't know how to add step to delete the content of the
> table "USER".
>
>         <route id="myimport">
>             <from uri="file:src/data/import/?charset=iso-8859-1" />
>             <split streaming="true" parallelProcessing="true">
>                 <tokenize token="\n" />
>                 <unmarshal>
>                     <csv delimiter=";" />
>                 </unmarshal>
>                 <setBody><simple>${in.body[0]}</simple></setBody>
>                 <to
>                     uri="sql:INSERT INTO USER (USER, FIRSTNAME, LASTNAME,
> LOCATION)
>                            VALUES (#, #, #, #)?dataSourceRef=myDS" />
>             </split>
>         </route>
>
> Any hint is highly appreciated.
>
> Thanks
> Oli
>
>
>
> <http://coders.talend.com>Talend Application Integration Division
> http://www.talend.com
>



--
Mime
View raw message