Thanks Christian. Works like a charm :-)
Oli
________________________________________
From: Christian Müller [[email protected]]
Sent: 15 November 2012 22:13
To: [email protected]
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 <[email protected]> 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
>
--