# Logstash JDBC, checking for 0 records

**URL:** <https://discuss.elastic.co/t/logstash-jdbc-checking-for-0-records/59705>\
**Category:** Logstash\
**Created:** [September 2, 2016, 7:52pm UTC](https://discuss.elastic.co/t/logstash-jdbc-checking-for-0-records/59705 "2016-09-02T19:52:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sombilat](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sombilat](https://discuss.elastic.co/u/sombilat)\
**Post date:** [September 2, 2016, 7:52pm UTC](https://discuss.elastic.co/t/logstash-jdbc-checking-for-0-records/59705/1 "2016-09-02T19:52:41Z")

</div>

How do I check for JDBC if it returns 0 records?

When I run JDBC, and it returns 0 records or has nothing to output. How do I say if the records retrieved are 0?

---

<div class="post-metadata">

**Author:** ![sombilat](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sombilat](https://discuss.elastic.co/u/sombilat)\
**Post date:** [September 2, 2016, 9:39pm UTC](https://discuss.elastic.co/t/logstash-jdbc-checking-for-0-records/59705/2 "2016-09-02T21:39:55Z")

</div>

To expand on this. If a JDBC runs and it returns 0 records. Does it still execute an event? If so, how do I detect it? If not, how do I get it to show 0 records retrieved?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 4, 2016, 7:55pm UTC](https://discuss.elastic.co/t/logstash-jdbc-checking-for-0-records/59705/3 "2016-09-04T19:55:18Z")

</div>

> Does it still execute an event?

No.

> If not, how do I get it to show 0 records retrieved?

I don't believe that's possible. Why is this important to you, i.e. what's the underlying problem you want to solve?

---

<div class="post-metadata">

**Author:** ![sombilat](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sombilat](https://discuss.elastic.co/u/sombilat)\
**Post date:** [September 5, 2016, 1:33pm UTC](https://discuss.elastic.co/t/logstash-jdbc-checking-for-0-records/59705/4 "2016-09-05T13:33:32Z")

</div>

Hello Magnus,

> [@](#):
>
> what's the underlying problem you want to solve?

When I run the JDBC, it runs every hour. I want to be able to find out if the query extracted records or not.  
When I run the JDBC and it returns resutls, I output a file which contents of the JDBC query. If not, I still output a file but with a content of "No records retrieved".

I tried using the generator plugin, to mock up an event when JDBC does not run. Although I was unable to place a scheduler for it.

Can you suggest a better way for tackling the problem when JDBC returns no records? And Recording the event.

Thanks,

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:39am UTC](https://discuss.elastic.co/t/logstash-jdbc-checking-for-0-records/59705/5 "2017-07-06T04:39:52Z")

</div>


