I have only been using ignition for a week so forgive me if this seems simple. But I am planning on putting this script in a tag so that I can log data everytime that data changes. However I have this table made and it says I have incorrect syntax near VARCHAR. I know that when doing the .value on the part number it returns a UNICODE so I have initialized the PartNumber column as a NVARCHAR.
Here I went to redo the table with NVARCHAR and when declaring the variable types with the query they usually turn blue. However, NVARCHAR has not. Is there some varaible declaration I could be missing here? When i realized that the tag was returning unicode last I just altered the table instead of drop and create.
Gotta give you credit for clean code, posted properly using the formatting tool, with the error encountered and the stack trace, and marking the solution post.
Well played, I wished this was common enough that it didn't warrant an acknowledgement.
Welcome aboard.
Probably not the best idea.
Depending on what exactly you want to log, you could use the historian, transaction groups, or maybe a gateway event. Putting this kind of operation on tag change scripts (if that was indeed your intention) might give your gateway a serious headache.
Avoid putting any i/o operations there, or anything more than a very basic computation actually.
I try as hard as I can to avoid using tag change scripts actually.
I have a Part Number that changes maybe twice every 8 hours on 8 Machines. If every machine changed at the same time, it would be simpler, however there is a schedule that changes daily for needs. I only need this data input into someplace that I can pull it out. My goal is to have a report that gives me the data of exactly what happened during the past 24 hours on all machines. Like I said I've only been using ignition for a week and am not sure the best process for this. Any tips would be greatly appreciated
Is the declaration the same system.db.runNamedQuery("Jacks_Project","TestQueryForReport", params)
or system.db.runNamedQuery("TestQueryForReport", params)
I know one is to specify the named query in the project. Does this also include the gateway event scripts? Thank you.
Don't code in gateway events. Create a function in the script library, and call it from the event.
Gateway events have weird scoping rules and behavior. Just don't take any risk and call library functions.