Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a job that calls an Oracle Stored Procedure so I have no ability to make any updates to the Stored Procedure. The Stored Procedure returns data in a cursor. My flow works great if the cursor contains data:
tDBSP -> tParseRecordSet -> rest of processing
The issue is that I need to take a specific action if there are no records returned from the SP, i.e. the recordset is empty. But in this situation, I just get 0 records out of the tParseRecordSet and the flow is done.
How can I handle this situation?
Hello JackieM,
Thank you for reaching out to the Qlik community.
Use a tFlowMeter or tDBSP → tDBRow with a COUNT check, then branch the flow.
Common pattern:-
Alternative (simpler):-
Below are the related Talend documentation that can help you:-
Hi @Rahul_Kale - Thank you for the reply. The issue is that when the cursor is empty, 0 rows come out of tParseRecordSet so it doesn't matter what components I have after tParseRecordSet as the flow dies with tParseRecordSet.
Your simpler suggestion is great but this is a vendor SP and I don't have access to see the code. So I can't write a select statement based on the query in the SP since I can't see what it is.
Hi @Rahul_Kale - I tried adding a tFlowMeter and the flow does seem to continue through it (with 0 rows):
However, I don't have a NB_LINE available to me from tFlowMeter to work with. I only have ERROR_MESSAGE:
I was ultimately able to resolve this issue by writing code in a tJavaRow component linked from tDBSP that determines if cursor is empty and takes appropriate action.
tDBSP -> tJavaRow -> (if cursor has data) -> tParseRecordSet
-> (if cursor doesn't have data) -> processing to handle empty cursor
Good to know that JackieM & Thank you for updating us.
Since the cursor returns no rows, tParseRecordSet has nothing to trigger on. Add a separate check after the SP call (row count/status variable if possible) and branch:
If you can’t change the stored procedure, use a counter/flag in Talend (e.g., tJavaFlex or an aggregate step) to detect when the flow finishes with zero records.