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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to retrieve the row count from a table?

Hi all,
I need to retrieve the row count of a table. How can I do this? 
For this I should execute a select query to the database (Oracle in my case).
Can I use the tOracleRow component to get this done? If so, please advice me.
Thanks,
thivanka.
Labels (2)
18 Replies
Anonymous
Not applicable
Author

Hi thivanka,
Feel free to let me know if it is OK with you.
Best regards
Sabrina
Anonymous
Not applicable
Author

Hi thivanka,
tAggregateRow component could help You.
If your using tmap then create another output link to tAggregateRow and select the required function from Operations Property of it.
Attached screen shots. Please find it.
0683p000009MEaT.png
0683p000009MEaY.png
0683p000009MEad.png
0683p000009MEVo.png
In other you can also use tFlowmeter.
Thanks & Regards
Dasari
_AnonymousUser
Specialist III
Specialist III

Hi Dasari,
Thank you for you support. I will try what you have given and get back to you.
Thanks,
thivanka.
Anonymous
Not applicable
Author

IF the table is really huge (say multi million records), one way  is to get it is from Oracle data dictionary tables.  select num_rows from dba_tables where table_name ='XYZ'.  The catch is that stats need to be collected. Again this solution is if the number of rows is so large that select count(1) from XYZ takes 1/2 hour and does not meet your SLAs
_AnonymousUser
Specialist III
Specialist III

Hi  xdshi,
Hi want to capture unused records from my toraclerow component. How can it be done?
Thanks,
Anuj 
llatinsky1652125276
Contributor
Contributor

Hello, Sabrina. I found this post from many years ago and tried to use your suggestion to get the count of rows selected from source (which is SQL Server) by getting the value of ((Integer)globalMap.get("tDBInput_2_NB_LINE"))) and compare it with the rows inserted into destination which is tDBOutputBulkExec_1 Amazon Redshift. I get the former value in my tBufferoutput without a problem but not the latter - this one is always null. Does the tDBOutputBulkExec act differently regarding rows inserted...? Thank you

Anonymous
Not applicable
Author

Hello,

Would you mind posting your job design screenshots on community which will be helpful for us to understand your situation very well?

Best regards

Sabrina

llatinsky1652125276
Contributor
Contributor

Thank you for considering my question, Sabrina. This is the job I am talking about - those are just straight copies from source (SQL Server to Destination - Redshift), and to check that my number of rows extracted from source matches the number of rows inserted into destination, I decided to use global variables to save each count and return it to the calling job for comparison or even use it inside the child job before committing the data to redshift. This is my design: (and I only started with Talend last month so please forgive me if I am off)

0695b00000RhmZcAAJ.pngSQL Server component:

llatinsky1652125276
Contributor
Contributor

0695b00000RhmaaAAB.pngRedshift component:

0695b00000RhmbTAAR.pngnow capture the output counts in tFixedFlowInput:

0695b00000RhmdFAAR.pngand this is my output to parent:

0695b00000RhmfVAAR.pngthe parent job has to check where any in count not equal the out count and report it or if the child job can compare them there and not commit to redshift when counts are not equal. I have a bunch of tables like that transferring data from sql server to redshift. The parent job right now just printing out the output parameters - messgae_in_1 shows the correct count but messge_out_1 - which should be coming from redshift shows null:

0695b00000RhmoSAAR.pngthi is java code for now just to see that the main job is getting the parameters from the child:

0695b00000RhmpQAAR.png 

this is the run window when I run the main job :

 

0695b00000Rhmu1AAB.pngthank you