question

Cindy Azuero avatar image
1 Like"
Cindy Azuero asked Logan Gold answered

How to query entries on a process flow

I'm working with a list on process flow where I'm pushing flowitems, one of which is called "idPapa".

When the list already has entries I need to know how many of these entries have one particular value of "idPapa". I tried to use SQL to do this, but the COUNT and the WHERE clause aren't working properly.

FlexSim 16.0.1
process flowquerysql
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

·
Logan Gold avatar image
2 Likes"
Logan Gold answered

There is an easier way to query entries on a Process Flow list other than trying to use the query() command. In fact, I do not think the query() command works with Process Flow lists like they do with Global Lists.

I have included a small example model to show you how you can get a count of list entries by using the Pull From List activity. Normally, this activity will pull matching entries from the designated list, then remove those entries from the list. However, there is a checkbox in the activity called "Do not remove entries from List". With this checked, the specified label will be populated with matching entries from the list, but the entries themselves will still be on the list after the pull occurs. We can then use a picklist option called Array Size on another activity to store the number of entries that were "pulled" (counted) from the list.

In the attached example model, I have tokens that are created every so often with an Inter-Arrival Source. I also use an Assign Labels activity after this Source to randomly set a label on each token named "id" to a value from 1 to 3. The token is then pushed onto an internal list along with the value of the id label. You'll notice that there is a Sink activity after the Push to List that the tokens should go to after a corresponding Pull from List activity is used. But since we are using the "Do not remove entries from List" option, the tokens will remain on the Push to List activity indefinitely.

I have a Schedule Source that creates a token at time 0 and a second token at time 50. The first token should go through all of the activities before the list has a chance to be populated. This is meant to show that the Decide activity is working correctly because the count label is 0 and the token is sent through the second connector.

The second token that is created at time 50 should be able to pull from a populated list. I set up the Pull from List activity so there is a 0 for both the Request Number and Require Number, which means the token will try to pull everything it can from the list. Then, the pulled values will be stored on a label called "count". The Query for this pull will try to pull anything with an id of 2. I also made sure to check the box for "Do not remove entries from List".

Next, I use an Assign Labels activity to overwrite the count label. The Value field uses the Array Size option (Array > Array Size) to give us the number of entries that are being stored on the label and stores that number back on the count label. So if the list had 5 entries in the list with an id of 2, the count label would first be used to store a reference to all 5 of those entries in an array, then this activity will overwrite the count label and it will store the number 5.

Finally, the Decide activity just uses a Conditional Decide Decision to see if the count label is greater than 0. If it is greater than 0, the token should go through the first connecter (named Greater than 0). If it is not greater that 0, then the token will go through the second connector (named 0) just like the first token did.


5 |100000

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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