# Conditional error when choosing jdbc\_streaming statement

**URL:** <https://discuss.elastic.co/t/conditional-error-when-choosing-jdbc-streaming-statement/105590>\
**Category:** Logstash\
**Created:** [October 27, 2017, 3:21pm UTC](https://discuss.elastic.co/t/conditional-error-when-choosing-jdbc-streaming-statement/105590 "2017-10-27T15:21:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LuigiAG](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@LuigiAG](https://discuss.elastic.co/u/LuigiAG)\
**Post date:** [October 27, 2017, 3:21pm UTC](https://discuss.elastic.co/t/conditional-error-when-choosing-jdbc-streaming-statement/105590/1 "2017-10-27T15:21:11Z")

</div>

Hello,

I am having an issue in my logstash 5.6.3 and I don't know why (tss those beginners 🙂 )  
Here is my code (some dummy code in here for my safety XD)

```
jdbc_streaming {
	jdbc_driver_library => "C:\Program Files\Microsoft JDBC Driver 6.0 for SQL Server\sqljdbc_6.0\enu\jre8\sqljdbc42.jar"
	jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
	jdbc_connection_string => "Server=itisworkinghere;database=itisworkinghere;ApplicationIntent=ReadOnly;"
	jdbc_user => "itisworkinghere"
	jdbc_password => "itisworkinghere"
	
	if [fields][ID] == "2"{
		statement => "select * from table1 tb where tb.id = :Id"
	}
	else if [fields][ID] == "3"{
		statement => "select * from table1 tb where tb.id = :Id"
	}
	else if [fields][ID] == "4"{
		statement => "select * from table1 tb where tb.id = :Id"
	}
	parameters => { "Id" => "%{[fields][ID]}"}			
	target => "[fields][table]"
}	

```

and the error

```
Cannot create pipeline {:reason=>"Expected one of #, => at line 30, column 6 (byte 736) after filter {jdbc_streaming { ...mycode... jdbc_password => \"itisworkinghere\"\n\t\t\n\t\tif "}

```

So as you can see, I think the problem come from the if statement, is there anything wrong??  
Can I not use conditional statement in plugin??

Thank you to have read until this point 🙂

---

<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:** [October 27, 2017, 5:26pm UTC](https://discuss.elastic.co/t/conditional-error-when-choosing-jdbc-streaming-statement/105590/2 "2017-10-27T17:26:25Z")

</div>

You can't have conditionals inside plugin blocks.

---

<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:** [November 24, 2017, 5:32pm UTC](https://discuss.elastic.co/t/conditional-error-when-choosing-jdbc-streaming-statement/105590/3 "2017-11-24T17:32:28Z")

</div>

Closed on November 24, 2017, 5:32pm UTC

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