question

Tamilselvan avatar image
0 Likes"
Tamilselvan asked Jason Lightfoot commented

Access token label in SQL Query

How to access the token label in the SQL query.

for example, comaparing the table value with the token.label

FlexSim 23.1.1
sql queries
· 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.

Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·

Hi @Tamilselvan, was Jason Lightfoot's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

What's the context of the SQL - a table query, or list pull?

In a table query you can either concatenate the value into the string or pass in parameters for the token. Normally you'll be using a field name in the table to match values:

Table result=Table.query("SELECT * FROM MyTable WHERE $1.myLabel=<TableField>",token);

where you'd replace <TableField> with the name of column you want to match.

In a list pull query you just need to refer to the token as puller:

WHERE puller.myLabel=<ListField>

again replacing <ListField> with the name of a field you've added to the list.


All of this is documented on this site and in the online documentation. Please go through all the tutorials.

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

Tamilselvan avatar image Tamilselvan commented ·

Hi @Jason Lightfoot

I am trying to Filter Some (x) value in my global table using the sql query, but that (x) is in my token label, that specific value has to filtered in global table.

For Example

Let's Consider i have Value : Station_1 in my token label(token.Value), i need to access the token label in Sql query and filter the Station_1. I should not query with the specific keyword, it should take the value from label dynamically.

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Tamilselvan commented ·

Please don't use Value as the label name - it's used elsewhere in FlexSim and additionally in the context of a label can seem meaningless (exception being monetary value).

If you want a subset of a global table containing rows where some column contains a value matching that of a token label, then I've already answered that above. If the fieldname is dynamic too then just concatenate that into the sql string in place of the <Fieldname> text, rather than typing a fixed field. If that fieldname has spaces then be sure to put [ ] around it.

Test this in a tiny example with a script in the script console or a custom code in a process flow and if it doesn't work for you post the example and we'll find out why.

1 Like 1 ·

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.