I don't know that it would be easy to return this as a return value from a classmethod. SQL-based interfaces have the ability to process a resultset, including an understanding that the calling code needs to iterate over the results. If the number of results can get very large, this can be necessary!
As such, I think you need to think about how you want to handle the results. You could use %SQL.Statement
to return a resultset of type %SQL.StatementResult
, but you won't make your interface very clear as the resultset is dynamically generated and would still require the caller to do any interation over the results. That could look something like this:
ClassMethod GetSample() As %SQL.StatementResult
{
// Note - this code uses %ExecDirect() as a shortcut.
// For more control over the resultset, instantiate a %SQL.Statement instance, and then call %Prepare() and %Execute()
Set tResultSet = ##class(%SQL.Statement).%ExecDirect(,"SELECT * FROM Test.xSample")
Quit tResultSet
}
You could also return a list of objects, but that could make use of a lot of memory if your table is large, and your calling code would still need to iterate over the results and know what properties exist. You may want to explain what you actually need to do with your results to get better answers.