question

Joerg Vogel avatar image
0 Likes"
Joerg Vogel asked Jordan Johnson answered

How can I evaluate attributes of the content of a queue in a SQL query?

I am trying to get sum of the physical length of all items in a queue. I think a "SUM" clause will do that, but I can't get even a reference to a single item in the queue. I tried the adjusted approach in Flexsim 16 and it worked. In the current version Flexsim 17.2.2 I get a table which contains "no data" entries. I have tried to cast the queue into different datatypes, which doesn't change anything, I have tried to get a reference by a rank, that doesn't work neither. The Tutorial method does not work from the section "Advanced Query Techniques" under "SQL queries". Passing the Flexscript function in Dot-syntax or classic structure makes no difference. If I execute the code in a script window, doesn't change anything. What is the current syntax to query the items in a queue?

FlexSim 17.2.2
queuequerysqltutorialsno data
· 4
5 |100000

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

Joerg Vogel avatar image Joerg Vogel commented ·
0 Likes 0 ·
Arun Kr avatar image Arun Kr Joerg Vogel commented ·

Hi Jörg Vogel,

It's working for me. I used $iter only to get a reference of the flow items inside the Queue. Also, there is a chance that, it can be a bug. Blank tables with red linings were appearing sometimes after performing a sum operation and then performing the code below. Not sure the exact cause.

Table result = Table.query("SELECT  $2 AS Item,$3 AS Name,$4 AS Size FROM $1 Queue",model().find("Queue1"),$iter(1),$iter(1).as(Object).name,$iter(1).as(Object).size.x);
result.cloneTo(Table("GlobalTable1"));
<br>

support-joerg.fsm

Regards,

Arun KR

1 Like 1 ·
support-joerg.fsm (14.4 KiB)
Joerg Vogel avatar image Joerg Vogel Arun Kr commented ·

Thanks, @Arun KR, I get a result of the size, even if the reference to the item contains in the table cell a "no data" entry. I thought, where no data is, there can not be a result at all. That is a mistake. There is data, but not visible.

Table resultQueue1 = Table.query("SELECT SUM($2) AS itemsQueueLength FROM $1",
/*$1*/model().find("Queue1"),
/*$2*/$iter(1).as(Object).size.x);

0 Likes 0 ·
Show more comments

1 Answer

·
Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered

To get the length of all the items in a queue, I used this code:

Table.query("SELECT SUM($2) FROM $1", model().find("Queue1"), $iter(1).as(Object).size.x)[1][1]

I couldn't replicate the issue on my machine (17.2.2).

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.