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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Use tLoop and pass SQL query result as upper limit to it

Hello,

 

i'm trying to pass the result of a sql query to a tLoop like this:

 

0683p000009M7rv.png

 

The query has a single integer as ouput (set via Edit schema) and basically counts how many blocks of  thousand rows are in the result.

This single int value should be passed to a tLoop component as upper limit.

0683p000009M7s0.png

 

I can set the value successfully in a tSetGlobalVar as String format.

0683p000009M7s5.png

 

But whatever i try for the tLoop component it hits either Null Exceptions or Conversions Errors when i try to convert to the int type required for the loop.

0683p000009M7sA.png

 

The tLoop looks like this for example:

0683p000009M7sF.png

I hit the same error if i try to use that conversion to Integer in the tSetGlobalVar, so it's not linked to a specific tLoop issue, but rather me doing the conversion wrong...

How must my job look to get the sql query result into the loop as upper limit?

How can i pass the int value to the tLoop?

 

Kind Regards

Thomas

 

 

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Your tSetGlobalVar shouldn't need the ....

((String)globalMap.get("row2.count_loop"))

All it should need is .....

row2.count_loop

This should already be a number (I assume an Integer) so when you read it in the tLoop you should just need to use....

((Integer)globalMap.get("myKey"))

The tSetGlobalVar just needs the row and column name in the value and the name must be what you want it to be called. You have left it as "myKey" in your job. When you want to read it's value, you will need to know what data type it is (my assumption is Integer) and then just retrieve it using it's name (in this case "myKey") like above.

View solution in original post

2 Replies
Anonymous
Not applicable
Author

Your tSetGlobalVar shouldn't need the ....

((String)globalMap.get("row2.count_loop"))

All it should need is .....

row2.count_loop

This should already be a number (I assume an Integer) so when you read it in the tLoop you should just need to use....

((Integer)globalMap.get("myKey"))

The tSetGlobalVar just needs the row and column name in the value and the name must be what you want it to be called. You have left it as "myKey" in your job. When you want to read it's value, you will need to know what data type it is (my assumption is Integer) and then just retrieve it using it's name (in this case "myKey") like above.

Anonymous
Not applicable
Author

Hi,

 

setting row2.COUNT_LOOP directly in the tSetGlobalVariable solved the problem!

I had already tried to set row2.count_loop in my attempts, but missed that it is actually case sensitiv.

 

It is now working like this:

0683p000009M7ZF.png

0683p000009M7sK.png

 

Kind Regards

Thomas