Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
cwaras
Contributor III
Contributor III

[resolved] globalMap.get in SQL Builder tas400input

Hi
1) In a tSQLServerinput i select one line with a year value (ex : year_value=2011)
2) In a tAS400input i would like use this year value to filter directly in the where clause
Something like
select
...
from...
where
...
and x=year_value
I try to do that with globalMap.get but it doesn't work
Is globalMap.get is usefull in a tas400input ?
How can i do that by an other way ?
Great thx
Labels (2)
1 Solution

Accepted Solutions
cwaras
Contributor III
Contributor III
Author

Well I finally found :
In the SQL Builder pop-up of the tAS400input, the code was good:
a.REX = "+ globalMap.get (" Year ") +"
But look more closely, in the thumbnail view of the query in the main window of the input tAS400 it became this:
a.REX = "/ + globalMap.get (" / Year / ") + /"
By removing the "/" it works ....
Bug or????
Thank you for your help anyway.

View solution in original post

4 Replies
Anonymous
Not applicable

Should work like this:
"select
...
from...
where
...
and x= +"globalMap.get("year_value")"+
and y = something
"
What is the exact error you are receving?
cwaras
Contributor III
Contributor III
Author

Hi Saukema
And a great thank for answer.
I hope you will can help me.
I will try to describe better my problem :
I work on TOS 5.0.3.
You can find the global job picture below.
1) i select one line with three columns in a tSQLSErverInput :
SELECT KWHODS.ODS_DIM_TEMPS.ID_TEMPS as Temps,
cast(cast(KWHODS.ODS_DIM_TEMPS.ID_ANNEE as int)*10 as varchar(5)) as Annee,
cast(cast(KWHODS.ODS_DIM_TEMPS.CD_MOIS as int) as varchar(2)) as Mois
FROM KWHODS.ODS_DIM_TEMPS
"Temps", "Annee" and "Mois" are all varchar type.
2) i link that (main link) with a tSetGlobalVar, you can see the setting in the picture below
3) I lnik my tSetGlobalVar with my tAS400Input (on component ok link) and i put this in the SQL Builder of the t1SS400Input:

select x, y, z ....
from A a
where ....
and cast(a.REX as varchar(5))=" + (string)globalMap.get("Annee") + "
and cast(a.RPERIO as varchar(2))=" + (string)globalMap.get("Mois") + "
--> When i execute i receive the error :
Exception in component tAS400Input_1
java.sql.SQLException: Elément syntaxique ANNEE n'est pas correct. Eléments possibles : FOR SKIP WITH FETCH ORDER UNION EXCEPT OPTIMIZE.
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:650)
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:621)
at com.ibm.as400.access.AS400JDBCStatement.commonPrepare(AS400JDBCStatement.java:1578)
at com.ibm.as400.access.AS400JDBCStatement.executeQuery(AS400JDBCStatement.java:2136)
at kwh.copy_of_copy_of_load_fai_axfile_fca200j2_ods_b_1_0.Copy_of_Copy_of_Load_Fai_Axfile_FCA200J2_ODS_b.tAS400Input_1Process(Copy_of_Copy_of_Load_Fai_Axfile_FCA200J2_ODS_b.java:2496)
at kwh.copy_of_copy_of_load_fai_axfile_fca200j2_ods_b_1_0.Copy_of_Copy_of_Load_Fai_Axfile_FCA200J2_ODS_b.tMSSqlInput_1Process(Copy_of_Copy_of_Load_Fai_Axfile_FCA200J2_ODS_b.java:788)
at kwh.copy_of_copy_of_load_fai_axfile_fca200j2_ods_b_1_0.Copy_of_Copy_of_Load_Fai_Axfile_FCA200J2_ODS_b.runJobInTOS(Copy_of_Copy_of_Load_Fai_Axfile_FCA200J2_ODS_b.java:7519)

Without the 2 lines with the globalMap.get the request work without error....
What's wrong ????
Great great thx for yor help....
Anonymous
Not applicable

It looks pretty much ok to me, just a few things I can think of

Did you add "" to the complete statement?
so
"
select x, y, z ....
from A a
where ....
and cast(a.REX as varchar(5))=" + (string)globalMap.get("Annee") + "
and cast(a.RPERIO as varchar(2))=" + (string)globalMap.get("Mois") + "
"

Another suggestion I have is to add the query to the db connection in the repository. I've noticed Talend handles quotes a bit different in some situations with the repository.
Do you have a lot of data in ANAEL table? ohterwise you might consider to solve it with a join in the tMap instead of setting global vars.
cwaras
Contributor III
Contributor III
Author

Well I finally found :
In the SQL Builder pop-up of the tAS400input, the code was good:
a.REX = "+ globalMap.get (" Year ") +"
But look more closely, in the thumbnail view of the query in the main window of the input tAS400 it became this:
a.REX = "/ + globalMap.get (" / Year / ") + /"
By removing the "/" it works ....
Bug or????
Thank you for your help anyway.