# runPrepQuery giving strange error, SQL command not properly ended

**URL:** <https://forum.inductiveautomation.com/t/runprepquery-giving-strange-error-sql-command-not-properly-ended/108730>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [July 21, 2025, 2:35pm UTC](https://forum.inductiveautomation.com/t/runprepquery-giving-strange-error-sql-command-not-properly-ended/108730 "2025-07-21T14:35:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [July 21, 2025, 2:35pm UTC](https://forum.inductiveautomation.com/t/runprepquery-giving-strange-error-sql-command-not-properly-ended/108730/1 "2025-07-21T14:35:11Z")

</div>

Code is executed from an system.util.invokeAsynchronous() (gateway scope).

> **Code**
>
> ```python
> current_data = system.tag.readBlocking([
> "[UNS]Machine01/Room01/Tag1",
> "[UNS]Machine01/Room01/Tag2"
> ])
> 	
> query = """
> SELECT op.operationid FROM operations op
> INNER JOIN operations_steps st
> ON op.operationid = st.operationid
> WHERE op.workorderid = ?
> AND JSON_VALUE(op.context, '$.iteration') = ?
> AND st.step = 7;
> """
> 
> step_exist = system.db.runPrepQuery(
> query,
> [
> current_data[0].value,
> current_data[1].value
> ],
> "DB"
> )
> 
> ```

I tested the query in the database and worked without problem. For some reason whenever I use the runPrepQuery it doesn't work.

The error says "Command not properly ended"???

```python
Caused by: com.inductiveautomation.ignition.client.gateway_interface.GatewayResponse$GatewayThrowable: ORA-00933: SQL command not properly ended

```

I know I'm missing something because I used these type of queries before...

Thanks in advance!

---

<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:** [July 21, 2025, 3:01pm UTC](https://forum.inductiveautomation.com/t/runprepquery-giving-strange-error-sql-command-not-properly-ended/108730/2 "2025-07-21T15:01:16Z")

</div>

Drop the semicolon, perhaps? JDBC expects single statements, so a statement divider should not be necessary.

---

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [July 22, 2025, 6:58am UTC](https://forum.inductiveautomation.com/t/runprepquery-giving-strange-error-sql-command-not-properly-ended/108730/3 "2025-07-22T06:58:25Z")

</div>

You were right, you are totally right. Thx!
