# JDBC and tracking\_column(s) questions

**URL:** <https://discuss.elastic.co/t/jdbc-and-tracking-column-s-questions/51997>\
**Category:** Logstash\
**Created:** [June 6, 2016, 7:56pm UTC](https://discuss.elastic.co/t/jdbc-and-tracking-column-s-questions/51997 "2016-06-06T19:56:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ron.west](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@ron.west](https://discuss.elastic.co/u/ron.west)\
**Post date:** [June 6, 2016, 7:56pm UTC](https://discuss.elastic.co/t/jdbc-and-tracking-column-s-questions/51997/1 "2016-06-06T19:56:21Z")

</div>

I have 2 questions about the jdbc and tracking columns that my google foo isn't coming up with a good answer for.

[https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html)

(my source server is a sql server 2008)

1. How do you use multiple tracking\_column at the same time. For example, my "table" is actually a view over multiple tables, so I need to have it select based on 2 columns (commandtime and commandid). I really don't want to have to build logstash task for each of the 10 tables in my view.

My query looks like:

"Select commandid, ...  
from History  
WHERE CommandID \> :sql\_last\_value  
Order by CommandTime asc,CommandID asc"

1. How do I handle auto reset of the sql\_last\_value? Everyday the base tables are renamed and new tables created at around midnight.

So the tracked id needs be reset to 0.  
Is there an easy way to detect that the current ID isn't valid (maybe expiring after 10 minutes or something)?

---

<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:** [June 8, 2016, 6:49pm UTC](https://discuss.elastic.co/t/jdbc-and-tracking-column-s-questions/51997/2 "2016-06-08T18:49:09Z")

</div>

> How do you use multiple tracking\_column at the same time. For example, my "table" is actually a view over multiple tables, so I need to have it select based on 2 columns (commandtime and commandid). I really don't want to have to build logstash task for each of the 10 tables in my view.

Concatenate those two columns in your SELECT clause and use that as the tracking column.

> How do I handle auto reset of the sql\_last\_value? Everyday the base tables are renamed and new tables created at around midnight.

Won't this be fixed if you follow my suggestion above?

---

<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:54am UTC](https://discuss.elastic.co/t/jdbc-and-tracking-column-s-questions/51997/3 "2017-07-06T04:54:03Z")

</div>


