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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Don't truncate output DB table if input row count is zero

Hi guys,

 

I have simple job to load data as it is from .csv file to MS SQLServer table :

 

0683p000009LwaC.png

 

 

There is a chance that the tFileInputDelimited component would not get the file at specified path. So in this case, input row count becomes 0 and truncating output table is totally ineffiecient. 

 

Is there any way to define a check like if input row count > 0 then only contrl should passed on to output table.

 

Pseudo code of requirement :

 

if count(NorthInventory_Rows > 0) {
       truncate the table raw_inventory_north and load data
} else {
      don't truncate the table raw_inventory_north  
}

 

Thank you !

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Use a tFileExist component to test for the existence of the file. Then use Run If triggers to choose your path based on that.

View solution in original post

8 Replies
Anonymous
Not applicable
Author

Use a tFileExist component to test for the existence of the file. Then use Run If triggers to choose your path based on that.

Anonymous
Not applicable
Author

@rhall, Thanks. this is what I was looking for. But its giving an error :

 

0683p000009LwaM.png

 

Anonymous
Not applicable
Author

Can you show your RunIf config? It looks like you may have an issue there. Alternatively can you show us line 1408 of your code for this job? Just go to the code tab and you will see where the error is from a red line on the right hand side.

Anonymous
Not applicable
Author

There is nothing as condition in if statement :

 

0683p000009LwZV.png

 

Nothing specified in condition as well :

0683p000009LwC7.png

What do I need to specify as condtion ?

 

I tried Global Variable 'EXISTS' as mentioned here, but no luck.

 

Anonymous
Not applicable
Author

Ah, that will be why. You need a condition in here. Just use this....

 

((Boolean)globalMap.get("tFileExist_1_EXISTS"))

The above will give you a boolean representing whether the file exists or not

Anonymous
Not applicable
Author


@rhall wrote:

Ah, that will be why. You need a condition in here. Just use this....

 

((Boolean)globalMap.get("tFileExist_1_EXISTS"))

The above will give you a boolean representing whether the file exists or not


This get it on to work. Many thanks for your time @rhall 0683p000009MACn.png

Anonymous
Not applicable
Author

Hi @rhall,

 

How can I check the same in below case :

 

0683p000009LwNe.png

 

So, if the output of tFlowMeter = O rows, prevent truncating the output MS SQL table.

Anonymous
Not applicable
Author

You could forget the FlowMeter and simply load the data to a tHashOutput. Use the component statistics (look in the bottom left corner of the Studio, you can expand the component name and drag out statistic values from there) to decide whether more than 0 rows have been loaded to the tHashOutput. If that is the case, load the data from a corresponding tHashInput to your DB component.

 

Your code for checking whether more than 0 rows have been written to your tHashOutput will look something like this....

 

((Integer)globalMap.get("tHashOutput_1_NB_LINE"))>0