One Star

Cannot pass context parameter value in the tFileFetch component

Hi All,
I'm using a tFileFetch component to generate a currency conversion xml file. The query for the same looks like this:
*%20from%20yahoo.finance.xchange(0)%20where%20pair%20in%20('VUVTHB','VUVTWD')%20limit%205000%20&env=store://datatables.org/alltableswithkeys
When run with the above query, it works perfectly fine and generates the desired xml file. But I want the string in bold to be substituted by a context parameter; I have defined the context parameter as currency_string and have given the default value of 'VUVTHB','VUVTWD'.
But when the above query is run using the context parameter, instead of substituting the context's value, it just considers "context.currency_string" as the desired string literal and not 'VUVTHB','VUVTWD'. Below is a snapshot of  the query and the wrong xml file generated.

"*%20from%20yahoo.finance.xchange(0)%20where%20pair%20in%20(\"+context.currency_string+\")%20limit%205000%20&env=store://datatables.org/alltableswithkeys"
<?xm
<?xml version="1.0" encoding="UTF-8"?>
-<query yahoo:lang="en-US" yahoo:created="2014-08-26T06:34:35Z" yahoo:count="1" xmlns:yahoo="">
<!-- total: 186 -->
<!-- engine9.yql.ne1.yahoo.com -->
-<results>
-<rate id="CONTEX">
<Name>CONTEXT.CURRENCY_STRING=X</Name>
<Rate>0.00</Rate>
<Date>N/A</Date>
<Time>N/A</Time>
<Ask>N/A</Ask>
<Bid>N/A</Bid>
</rate>
</results>
</query>
I am not able to understand what is wrong with the above syntax and why the context parameter is not able to pick up its value and substitute in the query. I normally use context variables dynamically but not sure why this ain't working.
Looking forward to your suggestions. Thanks in advance for your advice!!
Regards,
Arijit
6 REPLIES
Four Stars

Re: Cannot pass context parameter value in the tFileFetch component

I think your query should look like (escape char is not required)
"*%20from%20yahoo.finance.xchange(0)%20where%20pair%20in%20("+context.currency_string+")%20limit%205000%20&env=store://datatables.org/alltableswithkeys"

Try above. Also use print statement using tJava to confirm the query.

Thanks
Vaibhav
One Star

Re: Cannot pass context parameter value in the tFileFetch component

Hi Vaibhav,
Thanks for your reply!
I ran it by removing the escape char, but as expected the job returned an error 'HTTP/1.1 400 Bad Request' since the URI got terminated after it encountered the second '"'. Hence I had included the escape character. 
Just to give you more clarity, this is the screen shot of the component:

Regards,
Arijit
One Star

Re: Cannot pass context parameter value in the tFileFetch component

Sorry the screenshot didn't get through. I've attached it
One Star

Re: Cannot pass context parameter value in the tFileFetch component

sorry not able to attach screenshot, don't know why Smiley Sad
Four Stars

Re: Cannot pass context parameter value in the tFileFetch component

You will have to reduce the size of screenshot... have you tried using print statement to confirm the query using System.out.println(). You can also use Print Screen and Click and Paste feature.
This will let you know where is the issue.
One Star

Re: Cannot pass context parameter value in the tFileFetch component

Hi I've tried these methods but still it won't upload the image. I think I saw somewhere you cannot upload any screenshots unless you have 10 or more posts. Even the link/ URI that I posted wasn't complete as its not allowed for beginner members. Anyway I've attached a pdf below, lets see if that goes through!!
Have used the print statement and its substituting the context value correctly. Not sure why it isn't working fine in the tFileFetch component.
Doc1.pdf.pdf