<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Acess a Variable in a Query in FlexScript in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/acess-a-variable-in-a-query-in-flexscript/m-p/13516823#M28579</link>
    <description>&lt;P&gt;By the way, depending on how your table is setup, indexing, etc. it may be faster to just query all the rows with customer groups 1 through 10 in a single query, sorted by Customer Group, and have a single for loop over the result.&lt;/P&gt;&lt;PRE&gt;Table result = Table.query("SELECT * FROM Customers WHERE [Customer Group] &amp;gt;= 1 AND [Customer Group] &amp;lt;= 10 ORDER BY [Customer Group] ASC");
int customerGroup = 0;
for(int i = 1; i &amp;lt;= result.numRows; i++) {
  if(result&lt;I&gt;["Customer Group"] != customerGroup) {
    // Customer group changed
    customerGroup = result&lt;I&gt;["Customer Group"];
  }


  // createobject(...)
}&lt;BR /&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 11 May 2018 09:29:02 GMT</pubDate>
    <dc:creator>mischa_spelt</dc:creator>
    <dc:date>2018-05-11T09:29:02Z</dc:date>
    <item>
      <title>Acess a Variable in a Query in FlexScript</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/acess-a-variable-in-a-query-in-flexscript/m-p/13516820#M28576</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 18.0.3 ]&lt;/I&gt;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have much information in global tabels (from Excel). For my simulation logic I need access to these data and sometimes sort it.&lt;/P&gt;
&lt;P&gt;When I have FlexScript and make a query to create a new temporary table, can I include a variable like "i" or a token lable in the query?&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;for (int i = 1; i&amp;lt;=10; i++)
{
	Table result=Table.query("SELECT * FROM Customers \
		WHERE [Customer Group] = i) ;


	//Create items in a special queue dependant of i 
}&lt;/PRE&gt;
&lt;P&gt;How can I access the data in an other way?&lt;/P&gt;
&lt;P&gt;Thank you for helping.&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2018 14:04:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/acess-a-variable-in-a-query-in-flexscript/m-p/13516820#M28576</guid>
      <dc:creator>gesa_r</dc:creator>
      <dc:date>2018-05-09T14:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Acess a Variable in a Query in FlexScript</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/acess-a-variable-in-a-query-in-flexscript/m-p/13516821#M28577</link>
      <description>&lt;PRE&gt;Table result = Table.query("SELECT * FROM Customers \    
    WHERE [Customer Group] = $1", i) ;&lt;/PRE&gt;&lt;P&gt;The syntax &lt;EM&gt;$n&lt;/EM&gt; references the &lt;EM&gt;n&lt;/EM&gt;th additional parameter to .query(). You can use it in the FROM, WHERE and ORDER clause, e.g. the above could also be rewritten as&lt;/P&gt;&lt;PRE&gt;Table result = Table.query("SELECT * FROM $1 \
    WHERE [Customer Group] = $2", Table("Customers"), i);&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 May 2018 14:30:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/acess-a-variable-in-a-query-in-flexscript/m-p/13516821#M28577</guid>
      <dc:creator>mischa_spelt</dc:creator>
      <dc:date>2018-05-09T14:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Acess a Variable in a Query in FlexScript</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/acess-a-variable-in-a-query-in-flexscript/m-p/13516822#M28578</link>
      <description>&lt;P&gt;Thank you, that is what I was looking for.&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 08:55:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/acess-a-variable-in-a-query-in-flexscript/m-p/13516822#M28578</guid>
      <dc:creator>gesa_r</dc:creator>
      <dc:date>2018-05-10T08:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Acess a Variable in a Query in FlexScript</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/acess-a-variable-in-a-query-in-flexscript/m-p/13516823#M28579</link>
      <description>&lt;P&gt;By the way, depending on how your table is setup, indexing, etc. it may be faster to just query all the rows with customer groups 1 through 10 in a single query, sorted by Customer Group, and have a single for loop over the result.&lt;/P&gt;&lt;PRE&gt;Table result = Table.query("SELECT * FROM Customers WHERE [Customer Group] &amp;gt;= 1 AND [Customer Group] &amp;lt;= 10 ORDER BY [Customer Group] ASC");
int customerGroup = 0;
for(int i = 1; i &amp;lt;= result.numRows; i++) {
  if(result&lt;I&gt;["Customer Group"] != customerGroup) {
    // Customer group changed
    customerGroup = result&lt;I&gt;["Customer Group"];
  }


  // createobject(...)
}&lt;BR /&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 May 2018 09:29:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/acess-a-variable-in-a-query-in-flexscript/m-p/13516823#M28579</guid>
      <dc:creator>mischa_spelt</dc:creator>
      <dc:date>2018-05-11T09:29:02Z</dc:date>
    </item>
  </channel>
</rss>

