# Why does runPrepUpdate take a list and runNamedQuery take a dictionary for parameters?

**URL:** <https://forum.inductiveautomation.com/t/why-does-runprepupdate-take-a-list-and-runnamedquery-take-a-dictionary-for-parameters/74639>\
**Category:** Ignition\
**Created:** [June 6, 2023, 2:37pm UTC](https://forum.inductiveautomation.com/t/why-does-runprepupdate-take-a-list-and-runnamedquery-take-a-dictionary-for-parameters/74639 "2023-06-06T14:37:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [June 6, 2023, 2:37pm UTC](https://forum.inductiveautomation.com/t/why-does-runprepupdate-take-a-list-and-runnamedquery-take-a-dictionary-for-parameters/74639/1 "2023-06-06T14:37:08Z")

</div>

Why does runPrepUpdate take a list and runNamedQuery take a dictionary for parameters?

I think there is something for me to learn there.

---

<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:** [June 6, 2023, 2:41pm UTC](https://forum.inductiveautomation.com/t/why-does-runprepupdate-take-a-list-and-runnamedquery-take-a-dictionary-for-parameters/74639/2 "2023-06-06T14:41:40Z")

</div>

Because the parameter replacement method is different.

The `runPrep*` functions take a list and they assume that the first element of the list should replace the first `?` encountered in the provided query, and so on until the length of the list is reached.

Named Queries on the other hand use Named parameters, and so the function needs a way to identify which parameter the value should be substituted for.

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [June 6, 2023, 2:44pm UTC](https://forum.inductiveautomation.com/t/why-does-runprepupdate-take-a-list-and-runnamedquery-take-a-dictionary-for-parameters/74639/3 "2023-06-06T14:44:48Z")

</div>

Is runNamedQuery safe to call in a script on a button if the parameters are values and not query strings, but it is running a delete update?

Or do in need to convert these to runPrepUpdate?

---

<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:** [June 6, 2023, 2:51pm UTC](https://forum.inductiveautomation.com/t/why-does-runprepupdate-take-a-list-and-runnamedquery-take-a-dictionary-for-parameters/74639/4 "2023-06-06T14:51:00Z")

</div>

Yes, runNamedQuery is perfectly safe to call from a script if the parameters are not query strings. It's safe even if query strings are used so long as you are not allowing un-sanitized user input into those parameters.

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [June 6, 2023, 2:52pm UTC](https://forum.inductiveautomation.com/t/why-does-runprepupdate-take-a-list-and-runnamedquery-take-a-dictionary-for-parameters/74639/5 "2023-06-06T14:52:57Z")

</div>

Thanks, my brain was short circuiting.

I was pretty sure that was correct, but I also for some reason think first of runPrepUpdate as a more robust solution, though I think it is more like another tool rather than actually more robust.

---

<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:** [June 6, 2023, 3:01pm UTC](https://forum.inductiveautomation.com/t/why-does-runprepupdate-take-a-list-and-runnamedquery-take-a-dictionary-for-parameters/74639/6 "2023-06-06T15:01:05Z")

</div>

> [@zacharyw.larson](#):
>
> runPrepUpdate as a more robust solution, though I think it is more like another tool rather than actually more robust.

I would say it is actually the other way around. If you can use a named query you should.

The `runPrep*` functions are useful when you need to construct a query dynamically based on some user input, like filtering columns that are returned.

You can accomplish everything in the `runPrep*` functions that you can in Named queries, however, you end up with essentially the same query in multiple places. Named Queries solve this issue by centralizing the query to one place so that if you need to edit the query you only need to update it in one place.

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [June 6, 2023, 3:11pm UTC](https://forum.inductiveautomation.com/t/why-does-runprepupdate-take-a-list-and-runnamedquery-take-a-dictionary-for-parameters/74639/7 "2023-06-06T15:11:59Z")

</div>

Thanks
