This code snippet uses %ZEN.Auxiliary.jsonSQLProvider. The namespace and string of SQL can be edited for different situations. The class method "test" runs the code:
Class eduardlebedyuk.passQuestionParams
{
classmethod test(pValue = 50) {
s ns = $Namespace
zn "samples"
s tSQL = "SELECT ID, Name FROM Sample.Person WHERE Id > ?"
s tPR = ##class(%ZEN.Auxiliary.jsonSQLProvider).%New()
s tPR.sql = tSQL
s tPR.%Format = "tw"
s tPR.maxRows = 100
s tParam = ##class(%ZEN.Auxiliary.parameter).%New()
s tParam.value = pValue
d tPR.parameters.SetAt(tParam,1)
d tPR.%DrawJSON()
//d ##class(%ZEN.Auxiliary.jsonSQLProvider).%WriteJSONFromSQL(,,,,,tPR) //same thing
zn ns
}
}
(Originally posted to Intersystems CODE by @Eduard Lebedyuk, 5/13/15)
Here's a link to the code on GitHub