# JDBC Input last value overlap

**URL:** <https://discuss.elastic.co/t/jdbc-input-last-value-overlap/276188>\
**Category:** Logstash\
**Created:** [June 16, 2021, 7:14pm UTC](https://discuss.elastic.co/t/jdbc-input-last-value-overlap/276188 "2021-06-16T19:14:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)\
**Post date:** [June 16, 2021, 7:14pm UTC](https://discuss.elastic.co/t/jdbc-input-last-value-overlap/276188/1 "2021-06-16T19:14:50Z")

</div>

Is it possible to set the `sql_last_value` parameter to go back a set amount of time. So something like `:sql_last_value(-10s)` or something like that. I'm querying a db and getting anything that's been updated since the last time the query was run. However, it looks like there's some delay going on and it's missing updates.

---

<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:** [June 16, 2021, 8:33pm UTC](https://discuss.elastic.co/t/jdbc-input-last-value-overlap/276188/2 "2021-06-16T20:33:51Z")

</div>

I have not tested it, but I believe :sql\_last\_value is just substituted using the value from the file. I cannot see a reason why you should not include standard SQL date math in the query that includes it.

---

<div class="post-metadata">

**Author:** ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)\
**Post date:** [June 16, 2021, 9:13pm UTC](https://discuss.elastic.co/t/jdbc-input-last-value-overlap/276188/3 "2021-06-16T21:13:59Z")

</div>

So you think this would work?

```auto
Select * from table where column1 > DATEADD(SECOND,-10,:sql_last_value)

```

---

<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:** [June 16, 2021, 9:16pm UTC](https://discuss.elastic.co/t/jdbc-input-last-value-overlap/276188/4 "2021-06-16T21:16:55Z")

</div>

> [@wwalker](#):
>
> So you think this would work?

I don't see why it wouldn't. Try it out and let us know 🙂

---

<div class="post-metadata">

**Author:** ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)\
**Post date:** [June 16, 2021, 9:23pm UTC](https://discuss.elastic.co/t/jdbc-input-last-value-overlap/276188/5 "2021-06-16T21:23:24Z")

</div>

Well, it caused Logstash to completely restart instead of just reloading the one pipeline....and it appears to be working...at least it isn't throwing errors. The logs APPEAR to show it working...

```auto
[2021-06-16T16:18:00,201][INFO][logstash.inputs.jdbc] (0.007883s) USE DB SELECT * FROM Table WHERE Date > DATEADD(SECOND,-10,'2021-06-16T16:17:30.763')
[2021-06-16T16:18:30,179][INFO][logstash.inputs.jdbc] (0.007237s) USE DB SELECT * FROM Table WHERE Date > DATEADD(SECOND,-10,'2021-06-16T16:18:00.169')

```

I'm seeing updates to the data so it looks like it's working. As always, thanks for the assistance Badger.

---

<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 14, 2021, 9:24pm UTC](https://discuss.elastic.co/t/jdbc-input-last-value-overlap/276188/6 "2021-07-14T21:24:09Z")

</div>

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