Using Array of Any for Bind Values or Fetch Results
You can use a parameter of type "Array of Any" in place of a list of bind values or in place of a list of fetch result variables for the Execute, Fetch, and Open methods. This is generally used when you don't know how many values are needed until the code runs.
For example, suppose that you had a SQL definition INSERT_TEST, that dynamically (that is, at runtime) generated the following SQL statement:
"INSERT INTO PS_TESTREC (TESTF1, TESTF2, TESTF3, TESTF4, . . . N) VALUES (:1, :2, %DateTimeIn(:3), %TextIn(:4)), . . . N";
Suppose you have placed the values to be inserted into an Array of Any, say &AAny:
&AAny = CreateArrayAny("a", 1, %DateTime, "abcdefg", . . . N);
You can execute the insert with the following:
&AAny = CreateArrayAny("a", 1, %DateTime, "abcdefg", . . . N); &SQL = GetSQL(SQL.INSERT_TEST); While /* Still something to do */ &SQL.Execute(&AAny); End-While; &SQL.Close();
Because the Array of Any promotes to absorb any remaining select columns, it must be the last parameter for the SQL object Fetch method or (for results) SQLExec. For binding, it must be the only bind parameter, as it is expected to supply all the bind values needed.