#1 2010-04-09 09:48:27

dosy07
Member
Registered: 2008-11-26
Posts: 17

SQL Query with parameters

Hi,

I create SQL query with parameters :
"select COUNT(*) from APPLICATIONFRC where APPLICATIONNAME = ? and APPLICATIONVERSION = ?"

How to pass parameters in tJavaDBInput with this query ?
tJavaDBInput do not accept row line, only iterate.


cdt,
Arnaud

Offline

#2 2010-04-09 09:52:08

shong
Talend team
Registered: 2007-08-29
Posts: 10301
Website

Re: SQL Query with parameters

Hello
tFileInputDelimited--row1--tFlowToIterated--iterate--tJavaDBInput---tLogRow
on tJavaDBInput, type in the sql as:
"select COUNT(*) from APPLICATIONFRC where APPLICATIONNAME ="+(String)globalMap.get("row1.columnName1")+" and APPLICATIONVERSION ="+(String)globalMap.get("row1.columnName2")

Best regards
Shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#3 2010-04-09 10:17:43

dosy07
Member
Registered: 2008-11-26
Posts: 17

Re: SQL Query with parameters

I know this solution but you cant use it with query defined in "DB connections>Queries" because query is  generic and you dont know the name of flow.

Offline

#4 2010-04-09 14:45:17

shong
Talend team
Registered: 2007-08-29
Posts: 10301
Website

Re: SQL Query with parameters

Hello

"DB connections>Queries" because query is  generic and you dont know the name of flow.

If you use the query from repository, you can change the query type from repository to built-in and edit the query.

Best regards
Shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#5 2010-04-09 15:52:04

dosy07
Member
Registered: 2008-11-26
Posts: 17

Re: SQL Query with parameters

Then there are no component to use Queries in repository with parameters like tMap ? its maybe a suggest, a new component for the futur

Offline

#6 2010-04-10 13:34:55

emaxt6
Member
Registered: 2008-08-04
Posts: 325

Re: SQL Query with parameters

Yeah, I agree, parametrizable queries would be a very welcomed and good feature in Talend, instead of going old-school with java string concatenation and escaping...

ie. a feature to accept queries that can use context or talend var seamlessly would be very good and provide clean syntax, ie.


"select field1, field2 from mytable where field1 = {context.var1}  and field2 = {context.var2}"


I think would be easy to implement Talend side given the possibility to use very well known templating opensource engine like Freemarker.

Last edited by emaxt6 (2010-04-10 13:35:29)

Offline

Board footer

Powered by FluxBB