Table refresh in all open sessions/clients

Can anyone suggest which is the best way to keep the table refreshed in all open sessions/clients where I want to keep the polling off for Query Binding.

I know system.db.refresh and refreshBinding works on current session/client.

At present,

  1. I keep a ‘datetime memory tag’ updated on every script end where the SQL data is modified.
  2. Placed a label component, bind to the memory tag in in view/window as ‘last update value’
  3. Written a script on value change to refresh the table data.
    This keeps on table data update on every open session/client.

Is this the correct way or any other suggestion to be more effective?

Adding a WHERE clause to your SQL, WHERE ‘datetime memory tag’ = ‘datetime memory tag’, will trigger a refresh every time ‘datetime memory tag’ changes.

1 Like

Hi @mcgheeiv,

Thanks for prompt response.
I got this error. May be due to a colon on the date format. I may need to change the date pattern in order to make it work.

Exception: Error running query:
SQLQuery(query=SELECT *
FROM Namelist
WHERE 2020-05-25 22:40:20.620 = 2020-05-25 22:40:20.620
caused by GatewayException: Incorrect syntax near ‘22’.
caused by SQLServerException: Incorrect syntax near ‘22’.

Ignition v8.0.10 (b2020031912)
Java: Azul Systems, Inc. 11.0.6

I would use system.util.sendMessage in the client that submits the SQL update. Broadcasting to all clients in the relevant project. The client message handler would then look up the window, and if open, issue the system.db.refresh() on the binding.

Use runPrepUpdate and pass your dates with ‘?’ a Named Query and pass your dates with :key placeholders. That eliminates the need to convert to string in your query and then convert the string back to date in your DB. It passes through as a date directly.

Hi @pturmel,

I was using memory tag value change script to broadcast a message within view/page scope and messageHandler on perspective table to refresh data, but i wasn’t aware that message scope to the level of client and gateway!
I will give a try on this.

Thanks a lot.

Hi @pturmel,
I was able to do this for vision client using getWindow() function.
How should I use these functions util.sendmessage and perspective.sendmessage to refresh table on all open perspective sessions?
Can you educate me with any suggestion?

@guganathan.r were you able implement this with perspective? I am doing something similar but the message handler being received seems to lag a bit and does not update immediately.