# Perspective system.db.runNamedQuery not writing all data variables

**URL:** <https://forum.inductiveautomation.com/t/perspective-system-db-runnamedquery-not-writing-all-data-variables/53920>\
**Category:** Ignition Early Access\
**Tags:** ignition81, perspective\
**Created:** [December 9, 2021, 3:28am UTC](https://forum.inductiveautomation.com/t/perspective-system-db-runnamedquery-not-writing-all-data-variables/53920 "2021-12-09T03:28:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jon.smith](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@jon.smith](https://forum.inductiveautomation.com/u/jon.smith)\
**Post date:** [December 9, 2021, 3:28am UTC](https://forum.inductiveautomation.com/t/perspective-system-db-runnamedquery-not-writing-all-data-variables/53920/1 "2021-12-09T03:28:38Z")

</div>

I can run the named query inside testing and all data fields populate. If i run it from a button with event onClick, only 4 of the data fields are written to the database, and the other 4 come back null.

 ![SavedQuery](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/4/24caa22e667e843772b2a91c0fe95dec208459c4.png)

script from the button

 ![buttonScript](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/c/fc48b6525f90f9ce5651d12f5177d26b3b2e8998.png)

results in mysql  
 ![mysql_results](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/5/1570316adfbc9d722371b9628fdb16943ec2487f.png)

Any ideas what I’m doing wrong? Its a simple form, then takes the data entered and inserts into the db.

---

<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:** [December 9, 2021, 3:49pm UTC](https://forum.inductiveautomation.com/t/perspective-system-db-runnamedquery-not-writing-all-data-variables/53920/2 "2021-12-09T15:49:05Z")

</div>

Simplest thing to try: Make sure that your values are actually populated and not null; e.g.:  
`print ticketnumber` right before the runNamedQuery call.

---

<div class="post-metadata">

**Author:** ![jon.smith](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@jon.smith](https://forum.inductiveautomation.com/u/jon.smith)\
**Post date:** [December 9, 2021, 4:09pm UTC](https://forum.inductiveautomation.com/t/perspective-system-db-runnamedquery-not-writing-all-data-variables/53920/3 "2021-12-09T16:09:08Z")

</div>

The form has data in each field, just not sure why it would not retrieve the value with the script and pass to the NamedQuery. Does the syntax look correct in the script? Not sure what I’m missing.

---

<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:** [December 9, 2021, 4:14pm UTC](https://forum.inductiveautomation.com/t/perspective-system-db-runnamedquery-not-writing-all-data-variables/53920/4 "2021-12-09T16:14:53Z")

</div>

Oh, hah.

Your parameter names don’t match up, e.g. on the named query it’s `ticket` (per your screenshot) but it’s `ticketnum` in your script.

---

<div class="post-metadata">

**Author:** ![jon.smith](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@jon.smith](https://forum.inductiveautomation.com/u/jon.smith)\
**Post date:** [December 9, 2021, 4:30pm UTC](https://forum.inductiveautomation.com/t/perspective-system-db-runnamedquery-not-writing-all-data-variables/53920/6 "2021-12-09T16:30:24Z")

</div>

I made sure they all match and I’m still receiving null values from the script. Very odd it will take some fields but not others.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [December 9, 2021, 4:33pm UTC](https://forum.inductiveautomation.com/t/perspective-system-db-runnamedquery-not-writing-all-data-variables/53920/7 "2021-12-09T16:33:51Z")

</div>

Do you have any triggers on the database table that might be resetting these values on the db end on insert? Worth a look.

---

<div class="post-metadata">

**Author:** ![jon.smith](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@jon.smith](https://forum.inductiveautomation.com/u/jon.smith)\
**Post date:** [December 9, 2021, 4:36pm UTC](https://forum.inductiveautomation.com/t/perspective-system-db-runnamedquery-not-writing-all-data-variables/53920/8 "2021-12-09T16:36:06Z")

</div>

No triggers that I am aware of. Here is detail of the simple table.

 ![datatable_details](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/c/4c4a1b54a6de3d22773184a744f7e60a94caea66.png)

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [December 9, 2021, 4:38pm UTC](https://forum.inductiveautomation.com/t/perspective-system-db-runnamedquery-not-writing-all-data-variables/53920/9 "2021-12-09T16:38:48Z")

</div>

Ok, try doing another sample but

`system.perspective.print(params)` right before your runNamedQuery and show us what you get in your print statement and then show us what the record is in the database.

With MySQL you would see any triggers under the table in the object explorer like this -  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/2/92390f165e850d3959765b196f15702ad67e4af5.png)

---

<div class="post-metadata">

**Author:** ![jon.smith](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@jon.smith](https://forum.inductiveautomation.com/u/jon.smith)\
**Post date:** [December 9, 2021, 5:38pm UTC](https://forum.inductiveautomation.com/t/perspective-system-db-runnamedquery-not-writing-all-data-variables/53920/10 "2021-12-09T17:38:29Z")

</div>

Okay, Ignition tech support resolved my issue. Turns out I was using my db column name in the script instead of the named query parameter name. The few fields that matched were lucky enough to pass through. Issue resolved when I changed the params = { “namedquery name”: ‘script variable’ }
