# runNamedQuery for Oracle Script Working but Returning The Following Error

**URL:** <https://forum.inductiveautomation.com/t/runnamedquery-for-oracle-script-working-but-returning-the-following-error/42271>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [January 14, 2021, 10:36pm UTC](https://forum.inductiveautomation.com/t/runnamedquery-for-oracle-script-working-but-returning-the-following-error/42271 "2021-01-14T22:36:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpence](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jpence](https://forum.inductiveautomation.com/u/jpence)\
**Post date:** [January 14, 2021, 10:36pm UTC](https://forum.inductiveautomation.com/t/runnamedquery-for-oracle-script-working-but-returning-the-following-error/42271/1 "2021-01-14T22:36:02Z")

</div>

Named Query:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/6/b6114dd074772764bd5f81cc7fe301b9dafa6312.png)

Script on Button Click:

```auto
def runAction(self, event):
	"""
	Method that will run whenever the selected event fires.

	Arguments:
		self: A reference to the component that is invoking this function.
		event: Events fired by the relevant mouse/touch interaction.
			altKey (bool): True if the 'alt' key was held down when the event
			               was fired.
			button (int | float): The button number that was pressed when the
			                      event was fired.
			buttons (int | float): The buttons being depressed when the event
			                       was fired.
			clientX (int | float): The X coordinate in local coordinates.
			clientY (int | float): The Y coordinate in local coordinates.
			ctrlKey (bool): True if the 'ctrl' key was held down when the event
			                was fired.
			metaKey (bool): True if the 'meta' key was held down when the event
			                was fired.
			pageX (int | float): The X coordinate relative to the whole
			                     document.
			pageY (int | float): The Y coordinate relative to the whole
			                     document.
			screenX (int | float): The X coordinate in global (screen)
			                       coordinates.
			screenY (int | float): The Y coordinate in global (screen)
			                       coordinates.
			shiftKey (bool): True if the 'shift' key was held down when the
			                 event was fired.
	"""
	params ={"organization_id":self.getSibling("organizationid").props.text, "batch_id":self.getSibling("batchID").props.text, "RTYQuery":self.getSibling("RTYType").props.value, "Reason":self.getSibling("Reason").props.text}
	
	system.db.runNamedQuery("UpdateException", params)

```

The result is that the data gets merged successfully but I get this error back from Oracle  
ORA-01002: fetch out of sequence

This seems to indicate that Ignition is running a script behind the scenes to fetch something against a cursor within the Oracle connection.

Any thoughts on how to mitigate this?

---

<div class="post-metadata">

**Author:** ![gabriel2](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/gabriel2/32/27208_2.png) [@gabriel2](https://forum.inductiveautomation.com/u/gabriel2)\
**Post date:** [October 27, 2022, 11:14am UTC](https://forum.inductiveautomation.com/t/runnamedquery-for-oracle-script-working-but-returning-the-following-error/42271/2 "2022-10-27T11:14:50Z")

</div>

Just got the same error running a single insert using **system.db.runPrepQuery** anyone suffered with this?  
Using Ignition 8.1.16 and Oracle 19c (But tested with 21c too!)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 27, 2022, 12:27pm UTC](https://forum.inductiveautomation.com/t/runnamedquery-for-oracle-script-working-but-returning-the-following-error/42271/3 "2022-10-27T12:27:16Z")

</div>

You are using multiple statements. JDBC doesn't officially support SQL scripts, just SQL statements. Some drivers accept it, but it isn't guaranteed.

Meanwhile, if running updates, use `runPrepUpdate`. JDBC will then know to obtain the affected rows count as the driver reply. If running a SELECT of any kind, use `runPrepQuery`. JDBC will then know that the reply is a data set.

You say you are inserting, which means you are using the wrong function.

---

<div class="post-metadata">

**Author:** ![gabriel2](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/gabriel2/32/27208_2.png) [@gabriel2](https://forum.inductiveautomation.com/u/gabriel2)\
**Post date:** [October 27, 2022, 4:19pm UTC](https://forum.inductiveautomation.com/t/runnamedquery-for-oracle-script-working-but-returning-the-following-error/42271/4 "2022-10-27T16:19:13Z")

</div>

Omg!! I can't believe I've done that!!!
