A Table contains methods and properties associated with manipulating table
data in FlexSim. A Table may be one of the following:
A Tree Table: This is a table whose data is defined in the tree structure. This
consists of a root node with one or more subnodes, each representing a row in the table. Subnodes
of each row represent cells in the table.
A Bundle Table: This is a table whose data is defined by a bundle node. This
consists of a node in the tree that contains bundle data.
A Query Result Table: This is a read-only in-memory table that contains the result
of a call to Table.query().
Bundle and tree tables can be stored anywhere in the model tree. Often they are stored as global tables,
or on object labels.
If no column index is specified the column will be added at the end.
If no datatype is specified the new column will copy the datatype of the previous column.
Do no remove, this fixes the anchor on doc.flexsim.com
addIndex(
Variant keyCol
,
int indexType = Table.IndexType.Unordered
)
Parameters
keyCol
A column name or number
indexType
The type of index desired. Can be either Table.IndexType.Unordered or Table.IndexType.Ordered.
Generally the default unordered value is sufficient. Table.IndexType.Ordered can be useful if you are querying the table with
Table.query() with a WHERE filter that uses a >, <,
>=, or <= comparison on the column.
Description
Adds an index to the specified column.
An index can significantly improve the performance of
the following operations:
Finding a value from the indexed column in a query (e.g. WHERE IndexedCol = SomeValue
An index can significantly slow performance to operations that change the table. If
a table changes frequently during the model run, an index is not recommended.
You can only add an index to a column in a Bundle table.
Do no remove, this fixes the anchor on doc.flexsim.com
If no row index is specified the row will be added at the end.
If no datatype is specified the cells will copy the datatype of the cells in the previous row.
Do no remove, this fixes the anchor on doc.flexsim.com
The row number containing the key value in the specified column.
If no match was found, returns 0.
Description
Searches a column for the specified key value.
If the keyCol is not specified, the first indexed
column in the table will be searched. If there is no indexed column, the first
column (column 1) will be searched.
If the column to search has an index, then the index will be used to look up
the correct row, rather than searching row by row.
Do no remove, this fixes the anchor on doc.flexsim.com
Searches a column for the specified key value, and returns one or more values from the matching row.
If the keyCol is not specified, the first indexed
column in the table will be searched. If there is no indexed column, the first
column (column 1) will be searched.
If the column to search has an index, then the index will be used to look up
the correct row, rather than searching row by row.
Once the matching row is found, the value in valueCol on that
row is retrieved. If valueCol is an array, the values from
each specified column will be retrieved, and returned as an array.
Do no remove, this fixes the anchor on doc.flexsim.com
Only used if you include $ syntax in the query. This defines additional, dynamically
evaluated parameters associated with the query. The value is a "lambda", a type that simply signifies that the parameter
is evaluated as-needed, not immediately when the method is called. You will usually either pass a reference to a
table node here, defining the table to query, or you will use the $iter() command in a FlexScript expression to
dynamically determine the value of a cell in a "virtual table." If this parameter defines a table, it must
be a tree-bound table or a direct reference to a node. In other words, it cannot
be the result Table of another call to Table.query(), unless you clone that result to a tree-bound table with
Table.cloneTo().
See Sql Query Examples for more information.
The resulting table. This is a read-only in-memory table (it is not stored on a node in the tree). Use
Table.cloneTo() to copy the result to a tree-bound
table.
Description
Executes an SQL query, returning the result as a Table.
Table result = Table.query("SELECT * FROM Customers ORDER BY Name");