Simple example for Read/Write/Subscription of internalSqlTag

I’m looking for a simple example for Read/Write/Subscription of SqlTag stored in ignition internal DB.

I don’t want to create a Sql tag provider like the example provided in the sdk v7.28

My tag (stored in ignition internal DB) are created with the ignition designer and i want Read/Write/Subscription the change of them from a Java Application or Module.

Best regards.


This can easily be done through the SQLTagManager, obtained through GatewayContext.getTagManager(). This interface has functions for reading/writing/subscribing. A few points:

  1. The read/write functions take an AuthenticatedUser, but this can be bypassed with the boolean argument “isSystem”. The idea is that modules that are allowed to run can read and write freely. So, you can pass a null user, and set that boolean to “true”.

  2. REMEMBER that in the gateway, you aren’t in a project, and don’t have a “default provider”. So, you need to fully qualify your tag paths. For example, the provider created by Ignition is called “default”, so if you wanted to read “MyTag”, you would create a tag path “[default]MyTag”. All the functions take tag paths, so you’ll want to use the TagPathParser. Example:

List<TagReadResult> results; TagPath path = TagPathParser.parse("[default]MyTag"); results = gatewayContext.getTagManager().read(Arrays.asList(path),null,true);
There are some other overloads of [tt]parse[/tt] that can help too (eg. [tt]parse(“default”,“MyTag”)[/tt])

Hope this helps,

thanks a lot,

but I’m a bit confuse to find the right class and interface for the write,
could you provide me an example ?

List writeResults;
TagPath pathEcr = TagPathParser.parse("[iti_partage]PAE1/Ligne1.Value");
BasicWriteRequest wr = new BasicWriteRequest(pathEcr, 1);
writeResults = context.getTagManager().write(Arrays.asList(wr),null,true);

=> i have the error BasicWriteRequest not applicable ?

Which BasicWriteRequest did you import? What’s the full text of the error you’re getting?

This is simply the exact same problem that you had before, you’re just getting to it through a different mechanism. Before, you were creating a list of , and I pointed out that the list must be . In this code, you’ve changed to using “Arrays.asList”, which is fine… except that, due to how generics work, you’re ending up with the same result- when you pass in a BasicWriteResult, Arrays.asList gives you back a List.

You have to cast the object to get back the write type of list:


These are the little quirks of generics in Java.