# \#namedqueries

**URL:** https://forum.inductiveautomation.com/tag/namedqueries/12.md

[Latest](https://forum.inductiveautomation.com/latest.md) · [Categories](https://forum.inductiveautomation.com/categories.md) · [Tags](https://forum.inductiveautomation.com/tags.md)

---

## [system.db.execQuery does not work but system.db.runNamedQuery does](https://forum.inductiveautomation.com/t/system-db-execquery-does-not-work-but-system-db-runnamedquery-does/117402)

<div class="topic-metadata">

**Author:** [@tuckercc](https://forum.inductiveautomation.com/u/tuckercc)\
**Replies:** 3\
**Last updated:** [October 8, 2026, 10:19pm UTC](https://forum.inductiveautomation.com/t/system-db-execquery-does-not-work-but-system-db-runnamedquery-does/117402 "2026-10-08T22:19:19Z")

</div>

I have a gateway tag change script that works. However, when I attempted to change from the system.db.runNamedQuery function to the system.db.execQuery function, it fails with the following error: Jython Exception occur…

---

## [Need help with Query Optimization Tool](https://forum.inductiveautomation.com/t/need-help-with-query-optimization-tool/116959)

<div class="topic-metadata">

**Author:** [@Ruchika](https://forum.inductiveautomation.com/u/Ruchika)\
**Replies:** 3\
**Last updated:** [September 2, 2026, 4:13pm UTC](https://forum.inductiveautomation.com/t/need-help-with-query-optimization-tool/116959 "2026-09-02T16:13:33Z")

</div>

I want to create a separate tool in Ignition Perspective for sql query optimization. This tool should show list of queries, time taken by them, whether it is slow/moderate and how it can be improved as well. Is it someth…

---

## [Best Database Architecture for Large-Scale OEE System (400+ Machines) – Named Queries vs Stored Procedures](https://forum.inductiveautomation.com/t/best-database-architecture-for-large-scale-oee-system-400-machines-named-queries-vs-stored-procedures/115655)

<div class="topic-metadata">

**Author:** [@Mohamed\_Shifan](https://forum.inductiveautomation.com/u/Mohamed_Shifan)\
**Replies:** 2\
**Last updated:** [June 1, 2026, 9:55pm UTC](https://forum.inductiveautomation.com/t/best-database-architecture-for-large-scale-oee-system-400-machines-named-queries-vs-stored-procedures/115655 "2026-06-01T21:55:39Z")

</div>

Hi Team, We are developing a large-scale Industry 4.0 OEE application in Ignition and would like suggestions regarding the best database interaction architecture for long-term scalability and performance. Our current e…

---

## [Named Query parameter datatype](https://forum.inductiveautomation.com/t/named-query-parameter-datatype/115694)

<div class="topic-metadata">

**Author:** [@rickard.eriksson](https://forum.inductiveautomation.com/u/rickard.eriksson)\
**Replies:** 3\
**Last updated:** [May 26, 2026, 8:19pm UTC](https://forum.inductiveautomation.com/t/named-query-parameter-datatype/115694 "2026-05-26T20:19:25Z")

</div>

Hi, Why is ignition generating queries with parameter as nvarchar(4000) even though i selected int4 in the designer? (@P0 nvarchar(4000))SELECT SAPNO from RECIPE\_MAIN where PRODUCTNO = @P0

---

## [Dynamically modified named query for a report](https://forum.inductiveautomation.com/t/dynamically-modified-named-query-for-a-report/112914)

<div class="topic-metadata">

**Author:** [@compuzak](https://forum.inductiveautomation.com/u/compuzak)\
**Replies:** 5\
**Last updated:** [December 19, 2025, 4:10pm UTC](https://forum.inductiveautomation.com/t/dynamically-modified-named-query-for-a-report/112914 "2025-12-19T16:10:14Z")

</div>

I have a vision window that allows the user to select filters for running reports. Some of the selections are the "from and through" type filters (like dates) and these can be handled via report parameters, but other se…

---

## [Expression for polling a named query](https://forum.inductiveautomation.com/t/expression-for-polling-a-named-query/110728)

<div class="topic-metadata">

**Author:** [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Replies:** 10\
**Last updated:** [September 20, 2025, 6:26pm UTC](https://forum.inductiveautomation.com/t/expression-for-polling-a-named-query/110728 "2025-09-20T18:26:34Z")

</div>

Hello, I am trying to run a named query based on a change in a PLC tag to update a perspective screen. I have a named query defined and which runs at an absolute rate. How to write an expression for poll rate field, to …

---

## [Ignition Named Query getting error](https://forum.inductiveautomation.com/t/ignition-named-query-getting-error/106691)

<div class="topic-metadata">

**Author:** [@dhiraj.pawar](https://forum.inductiveautomation.com/u/dhiraj.pawar)\
**Replies:** 2\
**Last updated:** [May 26, 2025, 2:53pm UTC](https://forum.inductiveautomation.com/t/ignition-named-query-getting-error/106691 "2025-05-26T14:53:29Z")

</div>

hello Team, Im getting error while executing name query please help me to understand this !\[image|690x387\](upload://hGkf1TYSM8iF1taSxE53PPZky1K.png)

---

## [Passing strings to scripts](https://forum.inductiveautomation.com/t/passing-strings-to-scripts/104732)

<div class="topic-metadata">

**Author:** [@dick.willis](https://forum.inductiveautomation.com/u/dick.willis)\
**Replies:** 5\
**Last updated:** [April 4, 2025, 10:21pm UTC](https://forum.inductiveautomation.com/t/passing-strings-to-scripts/104732 "2025-04-04T22:21:54Z")

</div>

I'm using a script to execute a named query. One of the parameters to the named query is a string. I've tested the named query and it works fine. But when I execute from a script, one of the fields does NOT get popula…

---

## [Understand MySQL Link To Vision Dropdown - Recipe Database](https://forum.inductiveautomation.com/t/understand-mysql-link-to-vision-dropdown-recipe-database/103292)

<div class="topic-metadata">

**Author:** [@Warren\_McDonald](https://forum.inductiveautomation.com/u/Warren_McDonald)\
**Replies:** 6\
**Last updated:** [March 5, 2025, 10:08pm UTC](https://forum.inductiveautomation.com/t/understand-mysql-link-to-vision-dropdown-recipe-database/103292 "2025-03-05T22:08:30Z")

</div>

I'm struggling to understand how to properly build out a recipe database tying Ignition and MySQL. I have run into so many roadblocks that I figured it might be worthwhile to ask for some help. My basic design is as fol…

---

## [Issues running namedqueries from script](https://forum.inductiveautomation.com/t/issues-running-namedqueries-from-script/101544)

<div class="topic-metadata">

**Author:** [@Morten\_Jepsen](https://forum.inductiveautomation.com/u/Morten_Jepsen)\
**Replies:** 10\
**Last updated:** [February 16, 2025, 8:33pm UTC](https://forum.inductiveautomation.com/t/issues-running-namedqueries-from-script/101544 "2025-02-16T20:33:43Z")

</div>

I have a script that is causing me some issues. I need it to run 2 sql queries depending on the value of the tag it is connected to. First issue is running the query. When i comment in the syste.db.runNamedQuery, it fai…

---

## [Not Authorized to Run Named Query From Script](https://forum.inductiveautomation.com/t/not-authorized-to-run-named-query-from-script/102179)

<div class="topic-metadata">

**Author:** [@Adam\_Shannon](https://forum.inductiveautomation.com/u/Adam_Shannon)\
**Replies:** 1\
**Last updated:** [February 11, 2025, 3:47pm UTC](https://forum.inductiveautomation.com/t/not-authorized-to-run-named-query-from-script/102179 "2025-02-11T15:47:09Z")

</div>

When calling a Named Query in script using system.db.runNamedQuery I get the Error in the Gateway Log "Not authorized to run query:" . I've tried setting permissions for Legacy Database Access in the project to no succe…

---

## [Postgres Namedquery In Clause](https://forum.inductiveautomation.com/t/postgres-namedquery-in-clause/100046)

<div class="topic-metadata">

**Author:** [@Alexandre\_Delizee](https://forum.inductiveautomation.com/u/Alexandre_Delizee)\
**Replies:** 3\
**Last updated:** [December 19, 2024, 4:58pm UTC](https://forum.inductiveautomation.com/t/postgres-namedquery-in-clause/100046 "2024-12-19T16:58:35Z")

</div>

Hi everyone, I'm currently in the process of creating a named query that will fetch valve\_data from a postgres database. This is done by running the following code: SELECT \* FROM valve\_data WHERE valve\_name IN (:ta…

---

## [Getting required precision from named query and event handler](https://forum.inductiveautomation.com/t/getting-required-precision-from-named-query-and-event-handler/99657)

<div class="topic-metadata">

**Author:** [@Rich\_Knoll](https://forum.inductiveautomation.com/u/Rich_Knoll)\
**Replies:** 5\
**Last updated:** [December 11, 2024, 9:10pm UTC](https://forum.inductiveautomation.com/t/getting-required-precision-from-named-query-and-event-handler/99657 "2024-12-11T21:10:01Z")

</div>

Hello, I have a button that I am triggering a named query from. Here is the script: params = { "HardwareIDParam": int(event.source.parent.getComponent('BagIDLabel').text), "QuantityParam": event.source.parent.getCom…

---

## [Using update, Insert and select query in a single named query on same database](https://forum.inductiveautomation.com/t/using-update-insert-and-select-query-in-a-single-named-query-on-same-database/99402)

<div class="topic-metadata">

**Author:** [@Amitkumar\_Ravat1](https://forum.inductiveautomation.com/u/Amitkumar_Ravat1)\
**Replies:** 7\
**Last updated:** [December 4, 2024, 2:46pm UTC](https://forum.inductiveautomation.com/t/using-update-insert-and-select-query-in-a-single-named-query-on-same-database/99402 "2024-12-04T14:46:32Z")

</div>

Can I use update, Insert and select query in a single named query on same database with query type as Query not Update type ? Insert into dbo.TableToUpdate(field1, field2) values (value1, value2) UPDATE dbo.TableToUpda…

---

## [Help trying to call a stored procedure](https://forum.inductiveautomation.com/t/help-trying-to-call-a-stored-procedure/98369)

<div class="topic-metadata">

**Author:** [@Leonardo\_Lozada](https://forum.inductiveautomation.com/u/Leonardo_Lozada)\
**Replies:** 4\
**Last updated:** [November 8, 2024, 9:28pm UTC](https://forum.inductiveautomation.com/t/help-trying-to-call-a-stored-procedure/98369 "2024-11-08T21:28:52Z")

</div>

I am trying to integrate a new PLC with an existing Oracle DB using Ignition. I need to call some stored procedures which I am trying to call using Named Queries, but I am getting an error message. Following two screens…

---

## [Perspective Map locations from db with markerColors based on db values](https://forum.inductiveautomation.com/t/perspective-map-locations-from-db-with-markercolors-based-on-db-values/98273)

<div class="topic-metadata">

**Author:** [@Andreas\_Wallevik](https://forum.inductiveautomation.com/u/Andreas_Wallevik)\
**Replies:** 4\
**Last updated:** [November 6, 2024, 2:44pm UTC](https://forum.inductiveautomation.com/t/perspective-map-locations-from-db-with-markercolors-based-on-db-values/98273 "2024-11-06T14:44:42Z")

</div>

Hi, I'm buliding a demo for a traffic-monitoring app for a customer. I have set up a simple db with Events, EventType and EventLocations I want lat and long coordinates from EventLocations to display on a map with diff…

---

## [Where Named Query execution](https://forum.inductiveautomation.com/t/where-named-query-execution/96523)

<div class="topic-metadata">

**Author:** [@Martin\_Wijaya](https://forum.inductiveautomation.com/u/Martin_Wijaya)\
**Replies:** 4\
**Last updated:** [September 27, 2024, 5:56am UTC](https://forum.inductiveautomation.com/t/where-named-query-execution/96523 "2024-09-27T05:56:25Z")

</div>

Hi, not sure this have been asked before. If we run the NamedQuery, where the execution will be process ? is it on the Ignition server or is on the SQL server ? Thank you

---

## [Adding a Primary Key to a database table](https://forum.inductiveautomation.com/t/adding-a-primary-key-to-a-database-table/96380)

<div class="topic-metadata">

**Author:** [@Alex\_Ford-King](https://forum.inductiveautomation.com/u/Alex_Ford-King)\
**Replies:** 4\
**Last updated:** [September 24, 2024, 4:35pm UTC](https://forum.inductiveautomation.com/t/adding-a-primary-key-to-a-database-table/96380 "2024-09-24T16:35:05Z")

</div>

I am trying to add an id column to my database table. The instructuional videos did not mention how to assign a primary key in a named query. Everything i try gives me a syntax error. Can someone please share what the na…

---

## [Why there is a Query Type in named queries?](https://forum.inductiveautomation.com/t/why-there-is-a-query-type-in-named-queries/96110)

<div class="topic-metadata">

**Author:** [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Replies:** 2\
**Last updated:** [September 18, 2024, 1:33pm UTC](https://forum.inductiveautomation.com/t/why-there-is-a-query-type-in-named-queries/96110 "2024-09-18T13:33:02Z")

</div>

Hello! Asking from the ignorance. Why does exists the Query Type in the named queries? I mean, I understand what does each type, but why not simply delete the query type and make all the queries work always? Any expl…

---

## [Request for Assistance with master named SQL Query Parameters](https://forum.inductiveautomation.com/t/request-for-assistance-with-master-named-sql-query-parameters/93606)

<div class="topic-metadata">

**Author:** [@Rajashekar\_Reddy](https://forum.inductiveautomation.com/u/Rajashekar_Reddy)\
**Replies:** 2\
**Last updated:** [July 23, 2024, 3:08pm UTC](https://forum.inductiveautomation.com/t/request-for-assistance-with-master-named-sql-query-parameters/93606 "2024-07-23T15:08:19Z")

</div>

HI, I am currently working on a project that requires the extraction of data from various SQL tables using a master named query. The challenge I am facing involves dynamically changing the table name for each execution,…

---

## [New Analysis causing fault on Database](https://forum.inductiveautomation.com/t/new-analysis-causing-fault-on-database/93142)

<div class="topic-metadata">

**Author:** [@Jack\_Jones](https://forum.inductiveautomation.com/u/Jack_Jones)\
**Replies:** 0\
**Last updated:** [July 12, 2024, 1:46pm UTC](https://forum.inductiveautomation.com/t/new-analysis-causing-fault-on-database/93142 "2024-07-12T13:46:09Z")

</div>

I have downloaded a project off of exchange to hopefully display alarm data. However when doing so I noticed that the alarm data it read required display paths to tell what the alarm was. So I went into a new UDT that I …

---

## [Named Query Between Dates DateTime Type](https://forum.inductiveautomation.com/t/named-query-between-dates-datetime-type/92957)

<div class="topic-metadata">

**Author:** [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Replies:** 3\
**Last updated:** [July 9, 2024, 4:30pm UTC](https://forum.inductiveautomation.com/t/named-query-between-dates-datetime-type/92957 "2024-07-09T16:30:21Z")

</div>

Trying to create a named query for values between two dates. If I have 2 DateTime parameters, can I use them directly with the SQL statement, or do I need to do something to match the datetime type of the MS SQL table? S…

---

## [Can I use Named Query Parameters to filter SQL Table in Vision?](https://forum.inductiveautomation.com/t/can-i-use-named-query-parameters-to-filter-sql-table-in-vision/92803)

<div class="topic-metadata">

**Author:** [@Roisin\_McGuire](https://forum.inductiveautomation.com/u/Roisin_McGuire)\
**Replies:** 4\
**Last updated:** [July 4, 2024, 3:15pm UTC](https://forum.inductiveautomation.com/t/can-i-use-named-query-parameters-to-filter-sql-table-in-vision/92803 "2024-07-04T15:15:21Z")

</div>

I am using a Named Query to display a pivot table from my database in Vision. The user doesn't need to see all columns and I would like to filter the columns without manually hiding the unwanted ones. Reproducible dummy…

---

## [Named query in a transform question](https://forum.inductiveautomation.com/t/named-query-in-a-transform-question/92555)

<div class="topic-metadata">

**Author:** [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Replies:** 6\
**Last updated:** [July 4, 2024, 3:41am UTC](https://forum.inductiveautomation.com/t/named-query-in-a-transform-question/92555 "2024-07-04T03:41:38Z")

</div>

Would it be bad practice to run a named query in a transform? I have a sql query that returns some data and a separate table that I cant inner join. So I want to loop the rows and run a named query to pull in the other …

---

## [Comments in named queries?](https://forum.inductiveautomation.com/t/comments-in-named-queries/53709)

<div class="topic-metadata">

**Author:** [@rvaught](https://forum.inductiveautomation.com/u/rvaught)\
**Replies:** 4\
**Last updated:** [June 26, 2024, 12:31pm UTC](https://forum.inductiveautomation.com/t/comments-in-named-queries/53709 "2024-06-26T12:31:08Z")

</div>

Have read several posts here that seem to clearly state that comments (in the SQL) cause problems, errors, index out of range etc. I’m assuming this is still the case? And that the (Settings) tab’s (Description) field …

---

## [0 values after casting varchar(50) to float in named query](https://forum.inductiveautomation.com/t/0-values-after-casting-varchar-50-to-float-in-named-query/92317)

<div class="topic-metadata">

**Author:** [@Rafal\_Samoraj](https://forum.inductiveautomation.com/u/Rafal_Samoraj)\
**Replies:** 2\
**Last updated:** [June 25, 2024, 9:46am UTC](https://forum.inductiveautomation.com/t/0-values-after-casting-varchar-50-to-float-in-named-query/92317 "2024-06-25T09:46:47Z")

</div>

Hello, In my named query I casted column ExternalLeakTestBackgroundResultmbarls which is varchar(50) to float. My column contain scientific notation of values. In SSMS it ok but in Ignition don\`t. My named query is: S…

---

## [Use named query parameter as db table column name to be updated](https://forum.inductiveautomation.com/t/use-named-query-parameter-as-db-table-column-name-to-be-updated/91778)

<div class="topic-metadata">

**Author:** [@Daniel\_Calderon](https://forum.inductiveautomation.com/u/Daniel_Calderon)\
**Replies:** 3\
**Last updated:** [June 12, 2024, 8:29pm UTC](https://forum.inductiveautomation.com/t/use-named-query-parameter-as-db-table-column-name-to-be-updated/91778 "2024-06-12T20:29:13Z")

</div>

Hi, I am trying to use a named query to update a value in one of four columns in a MySQL database table. However it looks like if I use a string parameter to tell the query the field to update it doesn't work. The value…

---

## [Perspective named queries DELETE FROM and foreign key conflict](https://forum.inductiveautomation.com/t/perspective-named-queries-delete-from-and-foreign-key-conflict/89937)

<div class="topic-metadata">

**Author:** [@Steven\_Cheron](https://forum.inductiveautomation.com/u/Steven_Cheron)\
**Replies:** 2\
**Last updated:** [May 6, 2024, 2:22am UTC](https://forum.inductiveautomation.com/t/perspective-named-queries-delete-from-and-foreign-key-conflict/89937 "2024-05-06T02:22:32Z")

</div>

Hi, I've created a named query on a table with a foreign key. My problem is when I want to delete a row which is used in the other table, the query fails and the script stops. The log in the gateway is the only place w…

---

## [Issues with Creating Query (Postgres DB)](https://forum.inductiveautomation.com/t/issues-with-creating-query-postgres-db/87919)

<div class="topic-metadata">

**Author:** [@Aisha\_Shiddat](https://forum.inductiveautomation.com/u/Aisha_Shiddat)\
**Replies:** 1\
**Last updated:** [March 26, 2024, 6:44pm UTC](https://forum.inductiveautomation.com/t/issues-with-creating-query-postgres-db/87919 "2024-03-26T18:44:08Z")

</div>

I am trying to create a simple named query from a Postgres DB and I keep getting an error: GatewayException: java.sql.SQLException: Unknown SQL type: 2003 caused by Exception: java.sql.SQLException: Unknown SQL type: 2…

---

## [Copy graphs from perspective to report pages](https://forum.inductiveautomation.com/t/copy-graphs-from-perspective-to-report-pages/65202)

<div class="topic-metadata">

**Author:** [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Replies:** 18\
**Last updated:** [February 26, 2024, 6:58pm UTC](https://forum.inductiveautomation.com/t/copy-graphs-from-perspective-to-report-pages/65202 "2024-02-26T18:58:00Z")

</div>

If I have a stacked bargraph on a Perspective page, is there an easy way to copy it to the Reports pages? Or do I need to reconstruct it?

[Next page](https://forum.inductiveautomation.com/tag/namedqueries/12.md?match_all_tags=true&page=1&tags%5B%5D=namedqueries)
