How do I write the value of SQL fields to tags

Simple. Basic. Brain Fog.
I have a query that gets the desired values.
How do I write the value of SQL fields to tags?

You mean like a Query Tag?

Query Tag is another new term to me. I'll look into it. Just need to get values returned from a query into ignition tags. I'd like to do this in a named query.

In that case maybe call a named query using system.db.runNamedQuery() in the gateway scripts, and then write these using system.tag.writeBlocking or system.tag.writeAsync to write to your tags


I also have the same question as it pertains to best practice of taking database values and writing them to tags.

You have multiple options. You can do as @Hayden_Watson suggested, create a a gateway timer script that runs a query on a schedule you decide on and then extract the values from the query results and write to tags.

You can also make a query with a SQL binding and put that on some polling rate.

If this is something that should only happen on certain events, doing the first method on a tag change event may be more appropriate.

You could also have one "source" dataset tag that is a SQL binding and then other tags that read from it with an expression.

More context would be required to know what is best for your use case. Part of it is personal preference too. I prefer to use expressions whenever possible because on the average they are faster than scripting, but sometimes you simply cannot do that.