Synthax to write an internal db tag

I try to write an internal db tag,

            List<TagResult> writeResults;
            TagPath pathEcr = TagPathParser.parse("default","test");
            	          
            BasicWriteRequest wr = new BasicWriteRequest(pathEcr, "1");
            
            List<BasicWriteRequest> lwr = new ArrayList<BasicWriteRequest>(1);
            lwr.add(wr);
                        
            writeResults = context.getTagManager().write(lwr,null,true);

I can’t buid => The method write(List, AuthenticatedUser, boolean) in the type SQLTagsManager is not applicable for the arguments (List, null,
boolean)

I try to user the TagWriteValueRequest, same message.
Could you please provide me a write example?

Hi,

That error (as with all compile time errors) isn’t a problem with the SDK, but simply with your syntax.

In this case, you’re running into a little quirk of generics: the function wants the interface “WriteRequest”… and while you’re making a list of items that implment that interface, it doesn’t match the signature exactly. Instead of declaring the list as , you need to declare it simply as , even though you are, in fact, putting BasicWriteRequests in it.

That is:

BasicWriteRequest wr = new BasicWriteRequest(pathEcr, "1"); List<WriteRequest> lwr = new ArrayList<BasicWriteRequest>(1); lwr.add(wr);

A bit confusing, perhaps, but unfortuately… that’s just Java.

Hi,

I try to replace BasicWriteRequest with WriteRequest, but I can’t buid, i
have the message : “Type mismatch: cannot convert from ArrayList to List<ConnectionTableNIO.WriteRequest>” on the line : BasicWriteRequest wr = new BasicWriteRequest(pathEcr, “1”);

List writeResults;
TagPath pathEcr = TagPathParser.parse(“default”,“test”);
BasicWriteRequest wr = new BasicWriteRequest(pathEcr, “1”);
List lwr = new ArrayList(1);
lwr.add(wr);
writeResults = context.getTagManager().write(lwr,null,true);

:frowning: i miss something ???

That's the wrong WriteRequest. Many things can have the same name, but will exist in different packages. In Eclipse, when you hit CTRL-Space and pick one, it will add an import statement for that package. In this case, you picked (or eclipse picked for you... it tends to do that sometimes) a "WriteRequest" from some other package. The one you want is "com.inductiveautomation.ignition.gateway.sqltags.model.WriteRequest"

Just delete the import from the top of the file that references NIO... and then ctrl-space on the WriteRequest in your code and pick the right one.

It’s OK, thanks a lot for your help.
I’ll check java interface uses…