# Not able to use postgres query with double quotes in jdbc\_streaming plugin

**URL:** <https://discuss.elastic.co/t/not-able-to-use-postgres-query-with-double-quotes-in-jdbc-streaming-plugin/311141>\
**Category:** Logstash\
**Created:** [August 1, 2022, 4:00pm UTC](https://discuss.elastic.co/t/not-able-to-use-postgres-query-with-double-quotes-in-jdbc-streaming-plugin/311141 "2022-08-01T16:00:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![grvGarg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grvgarg/32/103556_2.png) [@grvGarg](https://discuss.elastic.co/u/grvGarg)\
**Post date:** [August 1, 2022, 4:00pm UTC](https://discuss.elastic.co/t/not-able-to-use-postgres-query-with-double-quotes-in-jdbc-streaming-plugin/311141/1 "2022-08-01T16:00:40Z")

</div>

Hi

I am using jdbc\_streaming plugin. I have a complex query and also my postgres required double quotes (") with each table/column name.

I am also using Case When in my query, which requires apostrophe(').

Plugin does not support statement file path and if I use escape character() it give me error that query exception.

```auto
jdbc_streaming {
        jdbc_driver_library => "${LOGSTASH_JDBC_DRIVER_JAR_LOCATION}"
        jdbc_driver_class => "org.postgresql.Driver"
        jdbc_connection_string => "${LOGSTASH_JDBC_URL}"
        jdbc_user => "${LOGSTASH_JDBC_USERNAME}"
        jdbc_password => "${LOGSTASH_JDBC_PASSWORD}"
        statement => ' select
                        "ClosedDealId" as "closedDealId"
                       , CASE WHEN "IsCpo" = true then \'Certified Pre-owned\'
				when ("IsCpo" = false or "IsCpo" = null) and "IsNew" = true then \'New\'
				ELSE\ 'N/A\' END AS "vehicleType"
                        from dbo."ReplacementDeal"'
        target => "replacementDeal"
    }

```

Can anyone help me?

---

<div class="post-metadata">

**Author:** ![Ugo\_Sangiorgi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ugo_sangiorgi/32/146361_2.png) [@Ugo\_Sangiorgi](https://discuss.elastic.co/u/Ugo_Sangiorgi)\
**Post date:** [August 1, 2022, 4:46pm UTC](https://discuss.elastic.co/t/not-able-to-use-postgres-query-with-double-quotes-in-jdbc-streaming-plugin/311141/2 "2022-08-01T16:46:48Z")

</div>

You are not escaping that single quote in there (note the space):

```auto
ELSE\ 'N/A\' END AS "vehicleType"

```

it should be:

```auto
ELSE \'N/A\' END AS "vehicleType"

```

---

<div class="post-metadata">

**Author:** ![grvGarg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grvgarg/32/103556_2.png) [@grvGarg](https://discuss.elastic.co/u/grvGarg)\
**Post date:** [August 2, 2022, 9:22am UTC](https://discuss.elastic.co/t/not-able-to-use-postgres-query-with-double-quotes-in-jdbc-streaming-plugin/311141/3 "2022-08-02T09:22:59Z")

</div>

Oh sorry, this is just here while doing formatting it happened but issue still exist.

```auto
jdbc_streaming {
        jdbc_driver_library => "${LOGSTASH_JDBC_DRIVER_JAR_LOCATION}"
        jdbc_driver_class => "org.postgresql.Driver"
        jdbc_connection_string => "${LOGSTASH_JDBC_URL}"
        jdbc_user => "${LOGSTASH_JDBC_USERNAME}"
        jdbc_password => "${LOGSTASH_JDBC_PASSWORD}"
        statement => ' select
                        "ClosedDealId" as "closedDealId"
                       , CASE WHEN "IsCpo" = true then \'Certified Pre-owned\'
				when ("IsCpo" = false or "IsCpo" = null) and "IsNew" = true then \'New\'
				ELSE \'N/A\' END AS "vehicleType"
                        from dbo."ReplacementDeal"'
        target => "replacementDeal"
    }

```

---

<div class="post-metadata">

**Author:** ![Ugo\_Sangiorgi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ugo_sangiorgi/32/146361_2.png) [@Ugo\_Sangiorgi](https://discuss.elastic.co/u/Ugo_Sangiorgi)\
**Post date:** [August 2, 2022, 8:30pm UTC](https://discuss.elastic.co/t/not-able-to-use-postgres-query-with-double-quotes-in-jdbc-streaming-plugin/311141/4 "2022-08-02T20:30:56Z")

</div>

Can you share what error message you are seeing in Logstash?

---

<div class="post-metadata">

**Author:** ![grvGarg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grvgarg/32/103556_2.png) [@grvGarg](https://discuss.elastic.co/u/grvGarg)\
**Post date:** [August 3, 2022, 3:52am UTC](https://discuss.elastic.co/t/not-able-to-use-postgres-query-with-double-quotes-in-jdbc-streaming-plugin/311141/5 "2022-08-03T03:52:00Z")

</div>

I figured this out. Had to use below configuration in pipeline

```auto
config.support_escapes: true

```

---

<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 31, 2022, 3:52am UTC](https://discuss.elastic.co/t/not-able-to-use-postgres-query-with-double-quotes-in-jdbc-streaming-plugin/311141/6 "2022-08-31T03:52:11Z")

</div>

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