question

Maria Z3 avatar image
0 Likes"
Maria Z3 asked tannerp commented

SQL table query

Dear all,

I am rather new in Flexsim. Therefore, hopefully the question will be easy for you. I am trying to create a code for SQL query for a global table. I have created a very simple example and attached.

Basically, I am trying to retrieve 2 columns ( in my table and prioritize these columns based on the certain requirement. The table in real model is significantly longer than in the file attached.

I wanted to store the results in a dump table to see whether my logic is correct. I also want to assign a label to my token with the result of one value retrieved from table.

1. I am getting an error and cannot understand what I am doing wrong

2. I cannot see the results in a Dump Table

I would deeply appreciate, if you could help me or give a hint. sql-question.fsm

FlexSim 19.2.1
sql querytabletable queries
sql-question.fsm (18.8 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

Jordan Johnson avatar image
1 Like"
Jordan Johnson answered Kyle P commented

There are a couple issues with spacing in the query. Be sure that when you use the \ character, that you leave a space before it or on the next line after it. That character just continues the text to the next line, but does not add any white space. You also need to add spacing in your SELECT statement:

  1. // good
  2. SELECT * FROM Parameters \
  3.  
  4. // not good
  5. SELECT*FROM Parameters\

But beyond that, it looks like you are trying to filter by values in a certain row. Queries operate on columns rather than rows. If you want to use syntax like

  1. WHERE C > 5

then C needs to be a column.

Finally, while it would be really convenient to use token directly in your query, you won't be able to in this case. You will need to pass it in as a parameter, and use a placeholder for that parameter in your query:

  1. Table.query("... WHERE C > $1.Item.size ...", token)
· 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.