<?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: Parameterized SQL queries in the Database Connector in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/parameterized-sql-queries-in-the-database-connector/m-p/14067384#M100551</link>
    <description>&lt;P&gt;Thanks - this is what I was looking for.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So it seems I can use the existing Database Connector to make the connection and I can access the connection through something like:&lt;BR /&gt;&lt;SPAN class=""&gt;Database.Connection&lt;/SPAN&gt; &lt;SPAN class=""&gt;con&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;Database.Connection&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;"DBConnector1"&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;SPAN class=""&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;But I need to compose and run the query in FlexScript instead of entering it in the "Import" tab of the Database Connector menu.&lt;/P&gt;</description>
    <pubDate>Thu, 26 Mar 2026 13:05:09 GMT</pubDate>
    <dc:creator>sean_tully</dc:creator>
    <dc:date>2026-03-26T13:05:09Z</dc:date>
    <item>
      <title>Parameterized SQL queries in the Database Connector</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/parameterized-sql-queries-in-the-database-connector/m-p/14066595#M100540</link>
      <description>&lt;P&gt;Is it possible to parameterize a query in a Database Connector?&lt;/P&gt;&lt;P&gt;For example, say I want to run a SELECT query and have the ability to parameterize something in a WHERE clause, e.g.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;SELECT time, user, volume FROM MyDB.Streams WHERE snapshot = $1&lt;/LI-CODE&gt;&lt;P&gt;...where the parameter $1 could be linked to some variable in the model, such as a Parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By analogy, in python, using pyodbc I can do something like:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import pyodbc

# this is my parameter that will be inserted into the query
snapshot = 123 

pyodbc.connect( [INSERT CONNECTION DETAILS HERE] )
cursor = connection.cursor()
query = "SELECT time, user, volume FROM Streams WHERE snapshot = ?"
cursor.execute(query, snapshot)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 25 Mar 2026 21:29:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/parameterized-sql-queries-in-the-database-connector/m-p/14066595#M100540</guid>
      <dc:creator>sean_tully</dc:creator>
      <dc:date>2026-03-25T21:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Parameterized SQL queries in the Database Connector</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/parameterized-sql-queries-in-the-database-connector/m-p/14066910#M100542</link>
      <description>&lt;P&gt;For more information: &lt;A href="https://docs.flexsim.com/en/22.2/Reference/DeveloperAdvancedUser/SQLQueries/SQLQueries.html" target="_blank" rel="noopener"&gt;SQL Queries&lt;/A&gt;.&amp;nbsp;You can take a parameterized SQL with a table in FlexScript&lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2026 07:38:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/parameterized-sql-queries-in-the-database-connector/m-p/14066910#M100542</guid>
      <dc:creator>nguyenthanhnam2310</dc:creator>
      <dc:date>2026-03-26T07:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: Parameterized SQL queries in the Database Connector</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/parameterized-sql-queries-in-the-database-connector/m-p/14066913#M100543</link>
      <description>&lt;P&gt;You can bind parameters to a&amp;nbsp;&lt;A href="https://docs.flexsim.com/en/26.0/Reference/CodingInFlexSim/FlexScriptAPIReference/Database/Database.PreparedStatement.html" target="_blank" rel="noopener"&gt;prepared statement.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2026 07:02:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/parameterized-sql-queries-in-the-database-connector/m-p/14066913#M100543</guid>
      <dc:creator>FelixMoehlmann</dc:creator>
      <dc:date>2026-03-26T07:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Parameterized SQL queries in the Database Connector</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/parameterized-sql-queries-in-the-database-connector/m-p/14067384#M100551</link>
      <description>&lt;P&gt;Thanks - this is what I was looking for.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So it seems I can use the existing Database Connector to make the connection and I can access the connection through something like:&lt;BR /&gt;&lt;SPAN class=""&gt;Database.Connection&lt;/SPAN&gt; &lt;SPAN class=""&gt;con&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;Database.Connection&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;"DBConnector1"&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;SPAN class=""&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;But I need to compose and run the query in FlexScript instead of entering it in the "Import" tab of the Database Connector menu.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2026 13:05:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/parameterized-sql-queries-in-the-database-connector/m-p/14067384#M100551</guid>
      <dc:creator>sean_tully</dc:creator>
      <dc:date>2026-03-26T13:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: Parameterized SQL queries in the Database Connector</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/parameterized-sql-queries-in-the-database-connector/m-p/14068227#M100552</link>
      <description>&lt;P&gt;You can also find it in the Database.connection.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, here is my example code to import the data from the DatabaseConnector1 - new_table and place it into GlobalTable3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Database.Connection con = Database.Connection("DatabaseConnector1");&lt;BR /&gt;con.connect();&lt;BR /&gt;//return con.isConnected;&lt;BR /&gt;con.query("SELECT * FROM new_table").cloneTo(Table("GlobalTable3"));&lt;BR /&gt;con.disconnect();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2026 02:23:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/parameterized-sql-queries-in-the-database-connector/m-p/14068227#M100552</guid>
      <dc:creator>nguyenthanhnam2310</dc:creator>
      <dc:date>2026-03-27T02:23:39Z</dc:date>
    </item>
  </channel>
</rss>

