# Error When Using system.db.runPrepQuery

**URL:** <https://forum.inductiveautomation.com/t/error-when-using-system-db-runprepquery/86067>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [February 20, 2024, 11:32pm UTC](https://forum.inductiveautomation.com/t/error-when-using-system-db-runprepquery/86067 "2024-02-20T23:32:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pico\_Sankari](https://avatars.discourse-cdn.com/v4/letter/p/aeb1de/32.png) [@Pico\_Sankari](https://forum.inductiveautomation.com/u/Pico_Sankari)\
**Post date:** [February 20, 2024, 11:32pm UTC](https://forum.inductiveautomation.com/t/error-when-using-system-db-runprepquery/86067/1 "2024-02-20T23:32:31Z")

</div>

I'm trying to execute a basic SQL query.  
This is the code I'm using:

```auto
mq="SELECT MeltCount FROM M7Pour WHERE MeltCount>?"
data=system.db.runPrepQuery(mq,4)

```

This generates the error:

```auto
java.lang.Exception: java.lang.Exception: Error executing system.db.runPrepQuery(SELECT MeltCount FROM M7Pour WHERE MeltCount>?, , [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], )

```

I've tried converting my search (the 4 in the above code) to float, int, and string, but still get errors.

When I change my code to this:

```auto
mq="SELECT MeltCount FROM M7Pour WHERE MeltCount>4"
data=system.db.runPrepQuery(mq)

```

I don't get any errors and it returns the data I want. Is there some casting I need to do in my query or conversion I need to do for the value I'm searching? In the meantime I can add my search to the string being queried, but this seems like an unfortunate workaround.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 20, 2024, 11:34pm UTC](https://forum.inductiveautomation.com/t/error-when-using-system-db-runprepquery/86067/2 "2024-02-20T23:34:41Z")

</div>

It would be easier to confirm if you shared the full depth of the error stacktrace, _but_...  
You probably need to wrap your parameter list in square brackets, to make a list.  
As in:  
`data = system.db.runPrepQuery(mq, [4])`.  
Because the function expects some kind of multi-valued collection as a first step, _before_ it starts checking input types.

---

<div class="post-metadata">

**Author:** ![Pico\_Sankari](https://avatars.discourse-cdn.com/v4/letter/p/aeb1de/32.png) [@Pico\_Sankari](https://forum.inductiveautomation.com/u/Pico_Sankari)\
**Post date:** [February 20, 2024, 11:40pm UTC](https://forum.inductiveautomation.com/t/error-when-using-system-db-runprepquery/86067/3 "2024-02-20T23:40:16Z")

</div>

Thanks, this fixed it
