# Create one custom document if no data is retrive from the JDBC input

**URL:** <https://discuss.elastic.co/t/create-one-custom-document-if-no-data-is-retrive-from-the-jdbc-input/272326>\
**Category:** Logstash\
**Created:** [May 6, 2021, 5:47pm UTC](https://discuss.elastic.co/t/create-one-custom-document-if-no-data-is-retrive-from-the-jdbc-input/272326 "2021-05-06T17:47:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)\
**Post date:** [May 6, 2021, 5:47pm UTC](https://discuss.elastic.co/t/create-one-custom-document-if-no-data-is-retrive-from-the-jdbc-input/272326/1 "2021-05-06T17:47:27Z")

</div>

Hi, Its is posible to index one custom document if no data id retrieve from a database?  
how can logstash do this?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [May 6, 2021, 6:12pm UTC](https://discuss.elastic.co/t/create-one-custom-document-if-no-data-is-retrive-from-the-jdbc-input/272326/2 "2021-05-06T18:12:39Z")

</div>

A jdbc input creates one event for each row in a result set. If the set is empty it will not create an event. You could use two jdbc inputs, one to run the query, one to run a COUNT of the same query. If the count comes back as zero then create the custom document.

---

<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:** [June 3, 2021, 6:13pm UTC](https://discuss.elastic.co/t/create-one-custom-document-if-no-data-is-retrive-from-the-jdbc-input/272326/3 "2021-06-03T18:13:07Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
