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

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

joerg_vogel_HsH
Mentor Mentor
109 Views
5 Replies
Message 1 of 6

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

joerg_vogel_HsH
Mentor
Mentor

[ FlexSim 17.2.2 ]

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?

9341-query-code-help-not-functions.jpg

0 Likes
Accepted solutions (1)
110 Views
5 Replies
Replies (5)
Message 2 of 6

joerg_vogel_HsH
Mentor
Mentor
0 Likes
Message 3 of 6

arunTTT2P
Enthusiast
Enthusiast

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

Message 4 of 6

joerg_vogel_HsH
Mentor
Mentor

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
Message 5 of 6

arunTTT2P
Enthusiast
Enthusiast

Hi @Jörg Vogel, Can you show me this behavior as a model or screen shot? It seems working for me without any problem.

Regards,

Arun KR

0 Likes
Message 6 of 6

JordanLJohnson
Autodesk
Autodesk
Accepted solution

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).

.


Jordan Johnson
Principal Software Engineer
>

0 Likes