# Jdbc\_streaming filter plugin returns an empty set using parameters option

**URL:** <https://discuss.elastic.co/t/jdbc-streaming-filter-plugin-returns-an-empty-set-using-parameters-option/141042>\
**Category:** Logstash\
**Created:** [July 22, 2018, 4:29pm UTC](https://discuss.elastic.co/t/jdbc-streaming-filter-plugin-returns-an-empty-set-using-parameters-option/141042 "2018-07-22T16:29:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![realand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/realand/32/57515_2.png) [@realand](https://discuss.elastic.co/u/realand)\
**Post date:** [July 22, 2018, 4:29pm UTC](https://discuss.elastic.co/t/jdbc-streaming-filter-plugin-returns-an-empty-set-using-parameters-option/141042/1 "2018-07-22T16:29:53Z")

</div>

HELLO,

I'm using the jdbc input plugin to get data from "table1":

`statement => "SELECT * FROM table1 where id=1"`  
`Result is : id:1 and id_subscriber:1`

Then I'm using the **_jdbc\_streaming_** filter plugin to get more data from "table2" using the " **id\_subscriber**" field value from the previous statement, so I'm using the following statement :

```
statement => "SELECT * FROM table2 where id_subscriber = :idsub"
parameters => { "idsub" => "%{id_subscriber}"}
target => "arrayOfResults" #arrayOfResults is an empty array

```

While the folowing statement returns the four records I'm looking for :

```
statement => "SELECT * FROM table2 where id_subscriber = 1"
target => "arrayOfResults" # I get the right result

```

Can you tell me what Im I doing wrong ?

Thank you.

This is a part of the code :

```
input {
  jdbc {
    jdbc_connection_string => 'jdbc:mysql://MYSERVER
    ETC...
    statement => "SELECT * FROM table1 where id=1"
 }
  }
filter{
 jdbc_streaming  
 {  
    jdbc_connection_string => 'jdbc:mysql://MYSERVER2
    ETC...
    # NON WORKING STATEMENT
    statement => "SELECT * FROM table2 where id_subscriber = :idsub"
    # WORKING STATEMENT --> statement => "SELECT * FROM table2 where id_subscriber = 1"
    parameters => { "idsub" => "%{id_subscriber}"}
    target => "arrayOfResults"
  }
  json_encode {
    source => "arrayOfResults"
    target => "bar"
  }
  mutate {
    add_field => { "arrayOfResults" => "%{bar}" }
  } 
}
output {
  stdout { codec => json_lines }
  elasticsearch {
  'hosts' => 'localhost:9200'
  }
}
```

---

<div class="post-metadata">

**Author:** ![realand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/realand/32/57515_2.png) [@realand](https://discuss.elastic.co/u/realand)\
**Post date:** [July 22, 2018, 9:01pm UTC](https://discuss.elastic.co/t/jdbc-streaming-filter-plugin-returns-an-empty-set-using-parameters-option/141042/2 "2018-07-22T21:01:10Z")

</div>

Hello

My bad, I did not understand how the "parameters" option works.  
The right answer if someone came across this issue is simply :  
`parameters => { "idsub" => "id_subscriber"}`

The right sided part of **parameters** was referring to the field name and not it's value.

---

<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:** [July 23, 2018, 10:47am UTC](https://discuss.elastic.co/t/jdbc-streaming-filter-plugin-returns-an-empty-set-using-parameters-option/141042/3 "2018-07-23T10:47:41Z")

</div>

Yes. You only need to use the `%{id_subscriber}` type syntax when you need to create a string made of two fields or add a prefix/suffix.

The real reason why `%{id_subscriber}` did not work for you is that `%{id_subscriber}` will convert the numeric `id_subscriber` value into a string via interpolation and then the statement fails as 1 is not equal to "1".

---

<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:** [August 20, 2018, 10:49am UTC](https://discuss.elastic.co/t/jdbc-streaming-filter-plugin-returns-an-empty-set-using-parameters-option/141042/4 "2018-08-20T10:49:40Z")

</div>

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