# Logstash jdbc\_streaming, sql statement

**URL:** https://discuss.elastic.co/t/logstash-jdbc-streaming-sql-statement/169736
**Category:** Logstash
**Created:** [February 24, 2019, 5:36pm UTC](https://discuss.elastic.co/t/logstash-jdbc-streaming-sql-statement/169736 "2019-02-24T17:36:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![sahere37](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sahere37](https://discuss.elastic.co/u/sahere37)
#### Post date: [February 24, 2019, 5:36pm UTC](https://discuss.elastic.co/t/logstash-jdbc-streaming-sql-statement/169736/1 "2019-02-24T17:36:41Z")

</div>

hi all,  
I am using following logstash.conf file:

```
input {
jdbc {
    jdbc_driver_library => "F:\driver\sqljdbc_6.0\enu\jre8\sqljdbc42.jar"
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    jdbc_connection_string => "jdbc:sqlserver://local:3333;databaseName=TotalTXN"
    jdbc_user => "sss"
    jdbc_password => "sss"
    statement => "
	DECLARE @DDate1 CHAR(10)
   select @DDate1=REPLACE(MAX(Date),'/','') from TotalTXN.dbo.TotalTxn_Control
   select TOP 10 [BaseDate_Accept_Setel]
  ,[Financial_Date]
     from dbo.vw_TotalTXN where (BaseDate_Accept_Setel<=@DDate1) AND (BaseDate_Accept_Setel> :sql_last_value)
	"
use_column_value => "true"
tracking_column => "basedate_accept_setel"
}

}
filter {
         
jdbc_streaming {
 jdbc_driver_library => "F:\driver\sqljdbc_6.0\enu\jre8\sqljdbc42.jar"
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    jdbc_connection_string => "jdbc:sqlserver://local:3333;databaseName=TotalTXN"
    jdbc_user => "sss"
    jdbc_password => "sss"
    statement => "
	DECLARE @DDate2 CHAR(10)
	set @DDate2='%{Financial_Date}'
SELECT TotalTXN.dbo.d2md(@DDate2) as gdate"
target => "gdate"
}
mutate { replace => { "gdate" => "%{[gdate][0][gdate]}" } }
    mutate { gsub => ["gdate", "/", "-"] }
}

output {
  elasticsearch { 
    hosts => ["http://192.168.170.153:9200"]
    index => "a10_%{gdate}"
    user => "logstash_internal25"
    password => "x-pack-test-password"
 }
  stdout { codec => rubydebug }
}

```

in the jdbc\_streaming filter, I want to set the value of @DDate2 as the amount of "Financial\_Date" field. when i used following statement, it works and is ok,

```
DECLARE @DDate2 CHAR(10)
	set @DDate2='2019/02/24'
SELECT TotalTXN_OnLine.dbo.shd2md(@DDate2) as gdate

```

I want to set @DDate based on the value of "Financial\_Date",but (set @DDate2='%{Financial\_Date}') doesn't work, how can i handle this issue? any advice will be so appreciated. many thanks.

---

<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: [March 24, 2019, 5:36pm UTC](https://discuss.elastic.co/t/logstash-jdbc-streaming-sql-statement/169736/2 "2019-03-24T17:36:58Z")

</div>

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