# How to set \`input-jdbc\` statement let it can set variables？

**URL:** <https://discuss.elastic.co/t/how-to-set-input-jdbc-statement-let-it-can-set-variables/98825>\
**Category:** Logstash\
**Created:** [August 30, 2017, 9:03am UTC](https://discuss.elastic.co/t/how-to-set-input-jdbc-statement-let-it-can-set-variables/98825 "2017-08-30T09:03:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Moln](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@Moln](https://discuss.elastic.co/u/Moln)\
**Post date:** [August 30, 2017, 9:03am UTC](https://discuss.elastic.co/t/how-to-set-input-jdbc-statement-let-it-can-set-variables/98825/1 "2017-08-30T09:03:02Z")

</div>

How to set `input-jdbc` statement let it can set variables？  
e.g.:

```auto
input {
  jdbc {
    #...
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    statement => "select * from table_name_%{+yyyyMM}"
    #...
  }
}

```

Or is there another solution?

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [September 4, 2017, 12:22pm UTC](https://discuss.elastic.co/t/how-to-set-input-jdbc-statement-let-it-can-set-variables/98825/2 "2017-09-04T12:22:59Z")

</div>

You could try loading the statement from a file via `statement_filepath` then use scripting to add the `yyyyMM` to the table name.

---

<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:** [October 2, 2017, 12:23pm UTC](https://discuss.elastic.co/t/how-to-set-input-jdbc-statement-let-it-can-set-variables/98825/3 "2017-10-02T12:23:17Z")

</div>

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