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 {
mutate {
add_field => {"s_date" => "%{financial_date}"}
}
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"
parameters => {"mine" => "%{s_date}"}
statement => "
DECLARE @DDate2 CHAR(10)
set @DDate2=:mine
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 }
}
where Financial_Date is earned in jdbc input statement, i want to use the value of this field in jdbc streaming statement.
when i used following statement, it works and is ok.
DECLARE @DDate2 CHAR(10)
set @DDate2='2019/02/24'
SELECT TotalTXN_OnLine.dbo.d2md(@DDate2) as gdate
but using (set @DDate2=:mine) doesn't work, how can i handle this issue? any advice will be so appreciated. many thanks.