# Named Query Returning Output

**URL:** <https://forum.inductiveautomation.com/t/named-query-returning-output/83201>\
**Category:** Ignition\
**Tags:** namedqueries, perspective\
**Created:** [December 15, 2023, 6:31pm UTC](https://forum.inductiveautomation.com/t/named-query-returning-output/83201 "2023-12-15T18:31:29Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [December 15, 2023, 9:29pm UTC](https://forum.inductiveautomation.com/t/named-query-returning-output/83201/2 "2023-12-15T21:29:02Z")

</div>

It looks like maybe this is a snipit from your DB Managment system, if not then you should avoid SQL scripts, as SQL _ **scripting** _ isn't in the JDBC spec., even if some drivers tolerate them.

If this isn't already a stored procedure then it probably should be. There are multiple ways that a SP can be run from Ignition.

However, you should know that you can use `system.db.beginNamedQueryTransaction()` to create and run named queries in a transaction, you really don't need return the status of the transaction from the query. (If that is all the stored procedure is intended to do). If you do this, you should not use a transaction inside of the query or stored procedure.

Also, a named query by default returns the number of effected rows, which, would indicate if the transaction was committed or rolled back, as a rolled back transaction by definition can not effect any rows.

More information on when different tools for running queries in ignition should be used can be found here:

> [@runNamedQuery vs runPrepQuery](https://forum.inductiveautomation.com/t/runnamedquery-vs-runprepquery/81268/6):
>
> The original purpose of Named Queries was to make it possible to pass values into Vision Query bindings in a secure and efficient way, solving the unreliability of parameter stringification (looking at you, java.util.Date), and allowing the huge "legacy DB access" security hole to be closed. The maintenance advantages of NQs can be matched by multi-line strings for SQL in library scripts, so I tend to discount that item. However, not all is well. Some things to consider: NQs permit the use…

---

_[View the full topic](https://forum.inductiveautomation.com/t/named-query-returning-output/83201)._
