# Having environment variable in SQL file is not working

**URL:** <https://discuss.elastic.co/t/having-environment-variable-in-sql-file-is-not-working/107204>\
**Category:** Logstash\
**Created:** [November 10, 2017, 3:07pm UTC](https://discuss.elastic.co/t/having-environment-variable-in-sql-file-is-not-working/107204 "2017-11-10T15:07:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karthik\_S](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@Karthik\_S](https://discuss.elastic.co/u/Karthik_S)\
**Post date:** [November 10, 2017, 3:07pm UTC](https://discuss.elastic.co/t/having-environment-variable-in-sql-file-is-not-working/107204/1 "2017-11-10T15:07:04Z")

</div>

Hi,

I've tried below things but 1st one is working and the 2nd one is failing.

In command line i did "export SCHEMANAME=TEST "

1st One: **Worked**  
Conf file  
Plugin: JDBC  
statement=\> "select \* from ${SCHEMANAME}.TABLE1 "

2nd One: **Failed**  
Instead of having the sql directly in conf file, I copied the above sql and kept in the file called test.sql.  
Now my test.sql will be having below line.  
select \* from ${SCHEMANAME}.TABLE  
Conf file:  
statement\_filepath =\> "/logstash/test.sql"  
##Below line is commented  
#statement=\> "select \* from ${SCHEMANAME}.TABLE1 "

Does this supported ? Or Is there any other way to achieve this?

---

<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:** [December 8, 2017, 3:07pm UTC](https://discuss.elastic.co/t/having-environment-variable-in-sql-file-is-not-working/107204/2 "2017-12-08T15:07:30Z")

</div>

Closed on December 8, 2017, 3:07pm UTC

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