Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Talend Cloud AWS EU Scheduled Outage: Starting Tues 26 May 21:00 CEST with expected completion Wed 27 May 01:00 CEST
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

TRUNCATE TABLE ONLY IF NECESSARY

Hi,
i want read table and create different flow data filtering by a column.
For each flow i want truncate the target table of the flow only if the flow contain data.
It's possible to do?
See picture
0683p000009MEfx.png
Labels (2)
4 Replies
Anonymous
Not applicable
Author

It is possible, but not in the way describe. You have to check before if your query would return datasets (replace the result columns with a count(*)) and depending on the result you have to truncate the tables in separate tOracleRow components.
Probably you already though this, sorry there is no easy way to solve this.
alevy
Specialist
Specialist

The easiest way is include a row counter in each flow and put a tOracleRow between tMap and tOracleOutput. Make the statement something like: <row>.<column> == 1 ? "TRUNCATE TABLE <table>" : "SELECT Null"
Anonymous
Not applicable
Author

Hi,
how can I insert a row counter? I must use taggregaterow or something else? And after this:
<row>.<column> == 1 ? "TRUNCATE TABLE <table>" : "SELECT Null" --> I must truncate and insert if condition is true.
Whit your statement I can truncate but how can I insert?
Thanks in advance,
Gino.
alevy
Specialist
Specialist

Use e.g. Numeric.sequence("out1",1,1) in tMap to create a row counter. Make sure the sequence has a different name for each flow to a different table.
tOracleRow just does the truncation for the first row that passes through. tOracleOutput still does the insert.