# Graph property in SQL query

**URL:** <https://forum.cloverdx.com/t/graph-property-in-sql-query/697>\
**Category:** CloverDX Platform\
**Created:** [April 26, 2010, 12:00am UTC](https://forum.cloverdx.com/t/graph-property-in-sql-query/697 "2010-04-26T00:00:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![martind](https://avatars.discourse-cdn.com/v4/letter/m/ccd318/32.png) [@martind](https://forum.cloverdx.com/u/martind)\
**Post date:** [April 26, 2010, 12:00am UTC](https://forum.cloverdx.com/t/graph-property-in-sql-query/697/1 "2010-04-26T00:00:00Z")

</div>

Hi,

I have been trying to reproduce the example about DBInputTable from the wiki ([http://wiki.cloveretl.org/doku.php?id=c … inputtable](http://wiki.cloveretl.org/doku.php?id=components:readers#dbinputtable)) programmatically:

I translated:

```auto
<Property id="GraphParameter0" name="param1" value="A%"/>
  <Node id="INPUT" type="DB_INPUT_TABLE" dbConnection="NorthwindDB" DataPolicy="Strict" fetchSize="1000">
        <attr name="SQLCode">
            select * from employee_z where last_name = '${param1}'
        </attr>
  </Node>

```

to:

```auto
graph.getGraphProperties().put("param1", "Arthur");
Node nodeParser = new DBInputTable("INPUT", "NorthwindDB",
				"select * from employee_z where last_name = '${param1}'");

```

However it fails with the following exception:

```auto
java.sql.SQLException: Non supported SQL92 token at position: 232: param1
	at org.jetel.connection.jdbc.SQLDataParser.setDataSource(SQLDataParser.java:300)
	at org.jetel.component.DBInputTable.execute(DBInputTable.java:247)
	at org.jetel.graph.Node.run(Node.java:388)
	at java.lang.Thread.run(Thread.java:619)
Caused by: java.sql.SQLException: Non supported SQL92 token at position: 232: param1

```

This works:

```auto
select * from employee_z where last_name = 'Arthur'

```

Is the wiki still current?

---

<div class="post-metadata">

**Author:** ![avackova](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@avackova](https://forum.cloverdx.com/u/avackova)\
**Post date:** [April 27, 2010, 7:52am UTC](https://forum.cloverdx.com/t/graph-property-in-sql-query/697/2 "2010-04-27T07:52:09Z")

</div>

Hello Martin,  
parameters are instantiated, when graph is read from xml, so such direct parameter access doesn’t work from java code. To resolve parameters you have to use _graph.getGraphProperties().get…Property(“param”)_ instead of _${param}_

---

<div class="post-metadata">

**Author:** ![martind](https://avatars.discourse-cdn.com/v4/letter/m/ccd318/32.png) [@martind](https://forum.cloverdx.com/u/martind)\
**Post date:** [April 27, 2010, 2:43pm UTC](https://forum.cloverdx.com/t/graph-property-in-sql-query/697/3 "2010-04-27T14:43:23Z")

</div>

hi avackova,

Thanks for your help.

Does it mean that DBInputTable is not able to resolve parameters in SQL queries and that I should create a query with no parameters before passing it to the DBInputTable?

This is fine in case of Strings but if you want to use Dates and you don’t know their format in the database (or you want your query to be portable), this is problematic.

---

<div class="post-metadata">

**Author:** ![avackova](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@avackova](https://forum.cloverdx.com/u/avackova)\
**Post date:** [April 28, 2010, 7:06am UTC](https://forum.cloverdx.com/t/graph-property-in-sql-query/697/4 "2010-04-28T07:06:29Z")

</div>

Hello Martin,  
you can’t access parameters with this simple way (${param}), when you build your graph in java. And it doesn’t matter if you try to use it in DBOutputTable or anywhere else. Such defined parameters can be used only in xml graph definition. You can write your graph in xml (with parameters) and just run it from java (see cloverETL.examples.rel-2-9-2.zip/cloverETL/examples/javaExamples/testXMLGraph.java)
