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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
husibilski
Contributor
Contributor

Problems to handle context variables

Hallo,

I'm a newbie to Talend and Java. My problem is, how use context variables in a MSSQLInput component.

SELECT TOP (10)

       Upper([ResourceCspId])

      ,[Resource]

      ,([Quantity]) as 'Menge'

      ,[ResourceGroupName] as 'ResourceGrp'

      , [CustomerName] as 'Kunde'

      ,CONVERT(VARCHAR(10), [UsageStartUtc], 105) as 'Datum'

      ,'"+CSPBilling.DatumVon+"' as 'von'

      ,'"CSPBilling.DatumBis"' as 'bis'   

 FROM [csp].[AzureKosten]

 

In this example are 2 context variables CSPBilling.DatumVon  and CSPBilling.DatumBis. The variables are string and hold dates in the yyyy-mm-dd format. My problem is, that the variables will be replaced in runtime. I added some screenshots to show the situation (definition of the variables and result of the query. Thank you for any help.

 

regs

 

Hu0683p000009LqrX.jpg0683p000009Lqzx.jpg

 

Labels (4)
1 Solution

Accepted Solutions
vidya821
Creator
Creator

you use the object name as context and not the name of the context you have defined, so your query shud look like this
"SELECT TOP (10)

Upper([ResourceCspId])

,[Resource]

,([Quantity]) as 'Menge'

,[ResourceGroupName] as 'ResourceGrp'

, [CustomerName] as 'Kunde'

,CONVERT(VARCHAR(10), [UsageStartUtc], 105) as 'Datum'

,'"+context.DatumVon+"' as 'von'

,'"+context.DatumBis+"' as 'bis'"

View solution in original post

4 Replies
vidya821
Creator
Creator

you use the object name as context and not the name of the context you have defined, so your query shud look like this
"SELECT TOP (10)

Upper([ResourceCspId])

,[Resource]

,([Quantity]) as 'Menge'

,[ResourceGroupName] as 'ResourceGrp'

, [CustomerName] as 'Kunde'

,CONVERT(VARCHAR(10), [UsageStartUtc], 105) as 'Datum'

,'"+context.DatumVon+"' as 'von'

,'"+context.DatumBis+"' as 'bis'"
husibilski
Contributor
Contributor
Author

?Hi,


sorry it doesn't work. Same result.

mra802003
Contributor III
Contributor III

Can you try using "tContextLoad" component as you are loading context variables from external sources?

husibilski
Contributor
Contributor
Author

Now it is working. Thank you for helping me.

regs