Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Get sql records count

avatar
Explorer

I would like to get records count(select count(1) from table where col1=‘abc’) from a sql table. Could someone please help me with that ? 

1 ACCEPTED SOLUTION

avatar
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login
7 REPLIES 7

avatar

You can use ExecuteSQL pr ExecuteSQLRecord Processor for that. The first one will give you the result in avro format and the second one you can specify the format of the output by setting the record writer property.

avatar
Explorer

@SAMSAL I tried the above but it spits out multiple flowfiles.I just need the count(1) value

avatar

Can you please share the configuration for the executesql processor and any record writer you used. Also please share the flowfile output.

avatar
Explorer

nuxeonifi_0-1684515440053.png

I want the executeSQL to run just once and also if the count>0 then run another executeSQL to fetch records from another table

avatar
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login

avatar

It seems like the ExecuteSQL is being executed continuously because its scheduled to run as such based on the Run Schedule. You have to set up the Run Schedule to the needed frequency by selecting CORN Driven Scheduling Strategy and set the CRON Time accordingly in the Run Schedule property.

avatar
Explorer

@SAMSAL  - it worked ! Thanks