# system.db.runPrepQuery - Argument Syntax

**URL:** <https://forum.inductiveautomation.com/t/system-db-runprepquery-argument-syntax/59408>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [May 10, 2022, 2:54pm UTC](https://forum.inductiveautomation.com/t/system-db-runprepquery-argument-syntax/59408 "2022-05-10T14:54:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rwalters1](https://avatars.discourse-cdn.com/v4/letter/r/b9e5f3/32.png) [@rwalters1](https://forum.inductiveautomation.com/u/rwalters1)\
**Post date:** [May 10, 2022, 2:54pm UTC](https://forum.inductiveautomation.com/t/system-db-runprepquery-argument-syntax/59408/1 "2022-05-10T14:54:54Z")

</div>

Ignition / Vision:  
I have a Stored Function (PostgreSQL) that accepts an array of integers- The function executes as expected when called from pgAdmin as follows:  
SELECT \* FROM public.downtime\_record(1, 1000, ‘05/10/2022’, ‘0800 : 0900’, ‘{10, 11}’, ‘{1, 2}’, 1000)

However, when trying to execute this function from a script, it fails-  
system.db.runPrepQuery(‘SELECT \* FROM public.downtime\_record(?, ?, ?, ?, ?, ?, ?)’, [workcenterId, operationId, dateSlot, hourSlot, downtimeMinutes, downtimeId, partId])

I have my two array of integers being set as follows:  
downtimeMinutes = [10, 20]  
downtimeId = [4, 5]

This is the error that is generated:  
GatewayException: Can’t infer the SQL type to use for an instance of org.python.core.PyList. Use setObject() with an explicit Types value to specify the type to use.

What is the proper syntax for setting the two array variables?-

Thank you-  
Robert-

---

<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:** [May 10, 2022, 4:15pm UTC](https://forum.inductiveautomation.com/t/system-db-runprepquery-argument-syntax/59408/2 "2022-05-10T16:15:32Z")

</div>

Based on what you provided in the query from pgAdmin it looks like the function is expecting strings.

So

```auto
downtimeMinutes = '{10,20}'
downtimeId = '{4,5}'

```

Taging @pturmel because I don’t use postresql on a regular basis.

---

<div class="post-metadata">

**Author:** ![rwalters1](https://avatars.discourse-cdn.com/v4/letter/r/b9e5f3/32.png) [@rwalters1](https://forum.inductiveautomation.com/u/rwalters1)\
**Post date:** [May 10, 2022, 4:26pm UTC](https://forum.inductiveautomation.com/t/system-db-runprepquery-argument-syntax/59408/3 "2022-05-10T16:26:25Z")

</div>

Thanks for the reply- I had given the a try- downtimeMinutes = ‘{10,20}’  
But, then the error returned is it can’t find a function that matches the input types-  
Here is an image of the postgresql function with the arguments-

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/9/d99c157cc4dcc8019f5f16a6c489c4f1634f403a.png)

---

<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:** [May 11, 2022, 10:44am UTC](https://forum.inductiveautomation.com/t/system-db-runprepquery-argument-syntax/59408/4 "2022-05-11T10:44:55Z")

</div>

You cannot pass arrays through parameters in vanilla JDBC. Some DB’s offer extensions for that, including PostgreSQL, but such are not accessible through Ignition’s abstractions.

Use separate parameters for each endpoint.

---

<div class="post-metadata">

**Author:** ![rwalters1](https://avatars.discourse-cdn.com/v4/letter/r/b9e5f3/32.png) [@rwalters1](https://forum.inductiveautomation.com/u/rwalters1)\
**Post date:** [May 11, 2022, 11:34am UTC](https://forum.inductiveautomation.com/t/system-db-runprepquery-argument-syntax/59408/5 "2022-05-11T11:34:27Z")

</div>

Perfect- Thank you for your time - much appreciated-

---

<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:** [August 3, 2023, 3:19pm UTC](https://forum.inductiveautomation.com/t/system-db-runprepquery-argument-syntax/59408/6 "2023-08-03T15:19:57Z")

</div>

Follow up:

> [@Read/Write and Clear from an Array Tag (integer array)](https://forum.inductiveautomation.com/t/read-write-and-clear-from-an-array-tag-integer-array/74199/5):
>
> Does it work if you convert the list into a jarray first? v = [0,1,2,3] import jarray from java.lang import Integer v\_arr = jarray.array(v, Integer) To be honest I'm not even sure if array columns are supported or not, but see if this gets you to an error somewhere further.
