question

TOTH-EM avatar image
2 Likes"
TOTH-EM asked TOTH-EM commented

How to find a row in a table, and extract a value according to the item label?

Hi,

I have a table with some boxes that are labeled with an ID (box_id) and they all go through the same processor.

I also have a table with two collumns (Box_id and processing time) [cf. image].

How can I make my procecssor have a processing time that corresponds, regarding the table?

I naively tried this :

  1. Table qer = Table.query("SELECT [Processing time] FROM [Magical Boxes] WHERE BOX_id == $1", item.labels["box_id"]);
  2. return qer[1];

but it didn't work. I also tried to label the processor with the corresponding value, but the problem seems to come from the fact I cannot get the value from the table with the query.

Thanks,

--- EDIT ---

Using this in the processor worked.

  1. query("FROM [Magical Boxes] WHERE BOX_id == $1", item.box_id);
  2. return Table("Magical Boxes")[getquerymatchtablerow("Magical Boxes",1)][2];

--- EDIT 2 ---

After Mischa Spelt's comment, a better way would be to simply return qer[1][1] (faster and the first uses a deprecated command)

FlexSim 17.1.2
querysqltable commands
bx-query.png (4.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.

Steven Hamoen avatar image
1 Like"
Steven Hamoen answered TOTH-EM commented

@TOTH-EM I think that item.labels() returns a pointer to the label and you need the value so I guess that item.box_id would be better here.

· 3
5 |100000

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

Mischa Spelt avatar image
1 Like"
Mischa Spelt answered TOTH-EM commented

Since qer is a table, you need to get the value from the first row, first column:

  1. return qer[1][1];
· 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.

Clair A avatar image
1 Like"
Clair A answered TOTH-EM commented

Hello,

I think that the findmatch command is what you're looking for.

· 1
5 |100000

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