# Page doesn't refresh after performing an update query

**URL:** <https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706>\
**Category:** Ignition\
**Created:** [December 5, 2023, 7:56am UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706 "2023-12-05T07:56:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aleksej\_Goduljan](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Aleksej\_Goduljan](https://forum.inductiveautomation.com/u/Aleksej_Goduljan)\
**Post date:** [December 5, 2023, 7:56am UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/1 "2023-12-05T07:56:18Z")

</div>

Hi there.

I'm working with Ignition 8.1.24.

I created an update named query and execute it in the script using system.db. runNamedQuery.  
The function call always throws an error: The query did not return a result set.  
But the manipulations in the data base work. The function obviously just has problems writting the result (in this case it should be the amoung ot the affected rows).  
When I catch the error in the script, everything wokrs without issues, but I don't see the result in the view - I have to change something on the page or to set the data polling to 1 second or something to see the result of what my script does.  
Refreshing the page via script at the end also doesn't change anything on the situation.

To me it looks like a bug but I'm not sure.

Does anybody know this behavior?

Best  
Alex

---

<div class="post-metadata">

**Author:** ![Priyanka.Khandge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/priyanka.khandge/32/35989_2.png) [@Priyanka.Khandge](https://forum.inductiveautomation.com/u/Priyanka.Khandge)\
**Post date:** [December 5, 2023, 8:06am UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/2 "2023-12-05T08:06:52Z")

</div>

Use **refreshBinding** in your script like below:

[https://docs.inductiveautomation.com/display/DOC81/Perspective+Component+Methods#PerspectiveComponentMethods-RefreshingBindings](https://docs.inductiveautomation.com/display/DOC81/Perspective+Component+Methods#PerspectiveComponentMethods-RefreshingBindings)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/e/4e7529e824877d17682f5f9fb0efc54f0462a296.png)

---

<div class="post-metadata">

**Author:** ![Aleksej\_Goduljan](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Aleksej\_Goduljan](https://forum.inductiveautomation.com/u/Aleksej_Goduljan)\
**Post date:** [December 5, 2023, 10:33am UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/3 "2023-12-05T10:33:10Z")

</div>

It doesn't help. But thank you.

---

<div class="post-metadata">

**Author:** ![Priyanka.Khandge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/priyanka.khandge/32/35989_2.png) [@Priyanka.Khandge](https://forum.inductiveautomation.com/u/Priyanka.Khandge)\
**Post date:** [December 5, 2023, 10:35am UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/4 "2023-12-05T10:35:53Z")

</div>

Can you explain in more detail what is exactly your requirement?

Ignition Vision or Perspective?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 5, 2023, 11:22am UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/5 "2023-12-05T11:22:00Z")

</div>

But that's the solution, though. So if it doesn't work, it means you missed something somewhere... and we can't help with that if you don't tell us what you did and what didn't work.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [December 5, 2023, 11:37am UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/6 "2023-12-05T11:37:15Z")

</div>

Also, is the query type set to 'Update Query' in the named query editor?  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/1/010626496fcbe9db7a9f56c0a7f91b3095404fe1.png)

---

<div class="post-metadata">

**Author:** ![Aleksej\_Goduljan](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Aleksej\_Goduljan](https://forum.inductiveautomation.com/u/Aleksej_Goduljan)\
**Post date:** [December 5, 2023, 11:41am UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/7 "2023-12-05T11:41:51Z")

</div>

Perspective.  
I have a table with some data between two dates, which I can choose. I can select a row from that table and send the data from that row to another system using a button I created. In the table there is a column telling me, how many times I already sent the data from a certain row to the other system. At the end of the sending process I run an update query and add 1 to the number in that field. The query makes the updates I want, but throws me an error message: The query didn't give any result.  
If I catch this error in the script, everything works fine, only I dont see any result, unless I do something on the page (like choosing a different date) or set the polling on the table to a small number.  
Example:  
There's 2 in the field, I press the button, the query is run: I still see the 2.  
In my data base in the same line I see 3, which is the expected result.  
I refresh the page manually and only then I can see that 2 changed to 3.  
Your suggested solution with adding refreshBinding at the end of the script behind the button did not change anything.

---

<div class="post-metadata">

**Author:** ![Aleksej\_Goduljan](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Aleksej\_Goduljan](https://forum.inductiveautomation.com/u/Aleksej_Goduljan)\
**Post date:** [December 5, 2023, 11:42am UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/8 "2023-12-05T11:42:21Z")

</div>

Yes, I did that.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [December 5, 2023, 11:45am UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/9 "2023-12-05T11:45:47Z")

</div>

We might need to see some screenshots and code snips that demonstrate what you are doing.

@Priyanka.Khandge is correct... the refreshBinding is the proper way to refresh a binding in Perspective, but without knowing which object has which it is hard to point you in the correct direction.

---

<div class="post-metadata">

**Author:** ![Aleksej\_Goduljan](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Aleksej\_Goduljan](https://forum.inductiveautomation.com/u/Aleksej_Goduljan)\
**Post date:** [December 5, 2023, 12:21pm UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/10 "2023-12-05T12:21:57Z")

</div>

Here is the code:

```auto
def runAction(self, event):
import ast
	obj = some file path
	obj.Payload =  
       ast.literal_eval(self.getSibling("Table").props.selection.data[0].Payload)
obj.updateSelectedRow(str(self.getSibling("Table").props.selection.data[0].UUID))
	obj.execute()
	self.refreshBinding("custom.settings")

```

The last line I added today.

The fuction updateSelectedRow does just:

```auto
params = {"UUID":UUID}
system.db.runNamedQuery("sgl/interfaces/sap/SapTransactionLog_Update",params)

```

The execute function is just about sending data to SAP and works without issues.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [December 5, 2023, 12:28pm UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/12 "2023-12-05T12:28:14Z")

</div>

OK. So this

```auto
params = {"UUID":UUID}
system.db.runNamedQuery("sgl/interfaces/sap/SapTransactionLog_Update",params)

```

Is what is querying the database for the number you want to see? Is that the query that is giving your errors?

---

<div class="post-metadata">

**Author:** ![Aleksej\_Goduljan](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Aleksej\_Goduljan](https://forum.inductiveautomation.com/u/Aleksej_Goduljan)\
**Post date:** [December 5, 2023, 12:43pm UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/13 "2023-12-05T12:43:21Z")

</div>

This one just adds 1 to a certain field.  
It also gives me an error saying that the query did not return a result.  
But at the same time I see in the data base, that the the data are changed and the query actually did; what it was supposed to do.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [December 5, 2023, 12:55pm UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/14 "2023-12-05T12:55:50Z")

</div>

OK. Let's start at this query then.

Can you post the query? And a screen shot of how you have it defined in the Named Query?

---

<div class="post-metadata">

**Author:** ![Aleksej\_Goduljan](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Aleksej\_Goduljan](https://forum.inductiveautomation.com/u/Aleksej_Goduljan)\
**Post date:** [December 5, 2023, 1:11pm UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/15 "2023-12-05T13:11:31Z")

</div>

Here the query:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/3/73042f2143ab08a0da8c7ef991638135ca677786.png)

```auto
UPDATE Interfaces_SapTransactionLog
SET Sent2SAP = ISNULL(Sent2SAP,0) + 1 , Sent2SapOn = ISNULL(Sent2SapOn,GETUTCDATE())
WHERE UUID = :UUID

```

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [December 5, 2023, 1:14pm UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/17 "2023-12-05T13:14:26Z")

</div>

OK since that is an update query, nothing will be returned from that query.

You want the value of Set2SAP after that update is done correct?

If so, you will need to do the update and then do a separate Select query for that same data to display.

---

<div class="post-metadata">

**Author:** ![Aleksej\_Goduljan](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Aleksej\_Goduljan](https://forum.inductiveautomation.com/u/Aleksej_Goduljan)\
**Post date:** [December 5, 2023, 1:23pm UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/18 "2023-12-05T13:23:32Z")

</div>

I see.  
I guess that's the answer to my question.  
Thank you!

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [December 5, 2023, 1:24pm UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/19 "2023-12-05T13:24:22Z")

</div>

No problem. If you continue to have issues please just update this topic.

---

<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 5, 2023, 3:43pm UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/20 "2023-12-05T15:43:44Z")

</div>

NB: ast.literal\_eval is a performance nightmare. It's unlikely you need it at all, but you can likely replace it with the dict() builtin for the same end result with much better performance.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 5, 2023, 3:52pm UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/21 "2023-12-05T15:52:38Z")

</div>

> [@Aleksej\_Goduljan](#):
>
> `self.refreshBinding("custom.settings")`

Well.. I'm guessing your script is executed from a button. So, that means `self` is the button.  
You're trying to refresh the `custom.settings` property on the button itself... Which I doubt is what you actually want to do.  
You need to use `.refreshBinding` on the component that has the binding.

> [@paul-griffith](#):
>
> NB: ast.literal\_eval is a performance nightmare. It's unlikely you need it at all, but you can likely replace it with the dict() builtin for the same end result with much better performance.

I was gonna say... It's not the first time I see `ast` used for things that have nothing to do with actual ASTs. Where do people even find that idea ?

---

<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:** [December 5, 2023, 4:14pm UTC](https://forum.inductiveautomation.com/t/page-doesnt-refresh-after-performing-an-update-query/82706/22 "2023-12-05T16:14:27Z")

</div>

> [@pascal.fragnoud](#):
>
> Where do people even find that idea ?

I don't want to actually say it but I'm guessing it ends in "GPT"
