· Jun 9, 2023

How can I pass dynamic array of items to %ExecDirect method.

I am having code like this,

set args = []

set resultSet = ##class(%SQL.Statement).%ExecDirect( , sql_whereClause, args)

Instead of placing args[1],args[2] etc into the above I want to pass the whole args at a time if it possible.?

Discussion (5)1
Log in or sign up to continue

I had some doubt in your initial question.

NowYOUR mistake is evident
you compose a JSON array args=[arg1value,agr3value,arg3value,..]
using %Push(..)

to %SQL.Statement this is just kind of a strange structured String
%SQL.Statement doesn't deal with JSON Arrays or Objects

with arg... you have to pass a local variable array
which is a core structure of Object Script (since ever)

arg=3           ;;<max subscript count>

as already described by @Julius Kavay