The Talend txxxSqlOutput components give you an option to change the default "action on table" and one of these options is to clear the table or truncate it (see here for the differences). Alternatively, if you are wanting to initalise the database for the load of data every time and you don't need preprepared tables and custom indexes then you could use the drop table if exists and create
option to start afresh each time. The only problem with that option is that it won't do more than create a PK index, do datatypes, set lengths and set nullable/not nullable on fields. So if you need to add a lot of indexes in then you will lose those but then you could always add the indexes back in later and this would have the benefit of speeding up your initial insert too.
As always, you can use a database row component for executing custom SQL against the database and this includes DELETE
s, TRUNCATE
s and ALTER
s but I'd be inclined to use the graphical components that Talend provides wherever possible as it keeps the logic from filtering down to a separate level. You could use an ALTER
statement to set up indexes/complex keys after using a CREATE
statement in your inital DB output component too.
As a side note, I wouldn't put that kind of SQL statement into a stored procedure unless you have a requirement that no application performs ad-hoc SQL statements on the database and everything must be done by calling a sproc. This is typically only the case in public facing applications where it will be done for security reasons and allowing a DELETE
statement to be triggered externally sounds like a bad idea.