Using Class Queries - %SQL.Statement versus %Library.ResultSet
If I have defined a class query in one of my classes and I want to use that query from a method of another class, what are the pros and cons of using the %SQL.Statement interface versus the %Library.ResultSet interface?
I believe %SQL.Statement is the newer interface.
So if the old way is:
USER>s rs=##class(%Library.ResultSet).%New("%Library.File:FileSet") USER>s sc=rs.Execute("c:\s\","*.txt") USER>w sc 1 USER>while rs.%Next() {w !,rs.Data("Name")} ...
then the new way is:
USER>s oStmt=##class(%SQL.Statement).%New() USER>s sc=oStmt.%PrepareClassQuery("%Library.File","FileSet") USER>w sc 1 USER>s oResult=oStmt.%Execute("c:\s\","*.txt") USER>while oResult.%Next() {w !,oResult.%Get("Name")} ...
One drawback of the %SQL.Statement way is that it's harder for code analyzers such as Yuzinji to find the dependency between the calling method and the class query it uses.
Opinions welcome.