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

Announcements
Data Works for AI is here - Join the discussion and enter to win a pair of Qlik kicks: Join the Conversation!
cancel
Showing results for 
Search instead for 
Did you mean: 
JackieM
Contributor II
Contributor II

How to handle empty recordset from Stored Procedure

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?

 

Labels (1)
6 Replies
Rahul_Kale
Support
Support

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:-

  1. tDBSP → tParseRecordSet
  2. Add tFlowMeter after tParseRecordSet
  3. Use Run If (or OnComponentOk) with condition:tFlowMeter_1.NB_LINE == 0
  4. Route this to your “no data returned” action.
  5. Normal flow continues when NB_LINE > 0.

Alternative (simpler):-

  • Use tDBRow before/after the SP to call a SELECT COUNT(*) wrapper query and branch based on the result.

Below are the related Talend documentation that can help you:-

JackieM
Contributor II
Contributor II
Author

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.

JackieM
Contributor II
Contributor II
Author

Hi @Rahul_Kale - I tried adding a tFlowMeter and the flow does seem to continue through it (with 0 rows):

JackieM_0-1781875881298.png

However, I don't have a NB_LINE available to me from tFlowMeter to work with. I only have ERROR_MESSAGE:

JackieM_1-1781875952142.png

 

 

JackieM
Contributor II
Contributor II
Author

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

Rahul_Kale
Support
Support

Good to know that JackieM & Thank you for updating us.

william12342344
Contributor III
Contributor III

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:

  • Rows returned → normal processing
  • 0 rows → run your “no data” action

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.