question

Guillaume V avatar image
0 Likes"
Guillaume V asked Guillaume V commented

Please can someone help me write my QUERY?

Please help me, I am stuck...
I want to pull x2 tokens only if they have the same label "TEST" value in the list.
I do not care what value it is, just the fact that they have the same label value means that I want to pull them.

Any idea? I tried the function "COUNT()"but it didn't seem to be recognised by the Pull From List activity.

1626857968547.png

FlexSim 19.0.0
process flowquerysqlpullpullfromlist
1626857968547.png (165.7 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered Guillaume V commented

I don't know if you achieve this in the pull activity alone. I can offer a workaround though.

First, instead of using an internal list I created a global list for the entries so I can query it with "Table.query()". In the Assign Labels activity I search for labels that appear more than once on the list. If successful, that value gets returned and assigned to the "LabelVar" label on the token. If not, a null value gets returned.

  1. // Query for labels with more than one entry
  2. Table Identicals = Table.query("SELECT LABELTEST FROM List1 GROUP BY LABELTEST HAVING COUNT(LABELTEST) > 1");
  3.  
  4. if(Identicals.numRows > 0)
  5. {
  6. // If any are found return the first one
  7. return Identicals[1][1];
  8. }
  9.  
  10. // Else return null
  11. return nullvar;

Based on wether the label contains a valid value, the token then either waits for another value to be pushed to the list or continues on to the pull activity where it pulls the values based on the "LabelVar" label.

pullwhensamelabel.png

testnblabeltestidenticalinlist_1.fsm


· 6
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.