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: 
Anonymous
Not applicable

how to pass a variable in a tMSSQLInput based on a query ?

hello
I would like to use one SQL query that could vary based upon one variable, how can I pass this parameter in the SQL query ?
David
Labels (2)
25 Replies
Anonymous
Not applicable
Author

I think you could pass a (java) object too. But I haven't tried it.
If the variable is internal converted to a generic type like string, this should not work.
I think, give it a try and report the result 😉
Bye
Volker
_AnonymousUser
Specialist III
Specialist III

hi,
i have a table with columns like good, total, yield
i have to pick good and total column values and
insert yield= good*100/total
it is giving error. may be due to the same table
how can i do it?
Anonymous
Not applicable
Author

Can you give an example of your job? Where is your data stored, what error do you get?
If you use a database could your use UPDATE table SET yield = good*100/total WHERE xxx ?
Bye
Volker
Anonymous
Not applicable
Author

Hello raton
So I use a first tMysqlInput to get the keys (select id from id_table) --> Iterate --> tMysqlInput (select data from data_table where data_id = tMysqlInput.id)

For example:
tMysqlInput--row1-->tLogRow
|
iterate
|
tMySQLInput("select data from data_table where data_id ="+String.valueOf(row1.id))
Best regards

shong

Trying shong's solution, I find that, when there are quite few outputs from the 1st tMysqlInput (i.e. row1, and hopefully "iterate"), nothing's outputed from the 2nd tMysqlInput (row2). No data at all, when there should be some !
It's only with about 250 lines that I get data in row2.
Did I miss something ?
Anonymous
Not applicable
Author

I used a query like this and it worked fine using a context variable named context.FileName.
"select some_column from mytable where some_column = '"+context.FileName+"' "
It is similar to how you would create dynamic SQL if you were doing it in MSSMS.
Anonymous
Not applicable
Author

Hi Everyone,
For mssql input, I gave below query. But it is throwing an Exception "Conversion failed when converting date and/or time from character string".
select * from test where CREATE_DATE>CONVERT(datetime,'("+context.last_run_date+")') or modified_date>CONVERT(datetime,'("+context.last_run_date+")')
context.last_run_date is passing date as string(1950-01-01 00:00:00) which I am trying to convert as date datatype using CONVERT. 
Please suggest me the solution how to convert it.