Hi,
I would like to have a function, that (i) runs multiple SQL queries in background (connection and sql statements from string lists with arbitrary lengths), (ii) waits until all queries are finished, and (iii) returns a list of datatables. Please find my code below. I don't know how to gather the data tables correctly.
Thank you in advance.
Run_SQL_Queries = Function({o_connections, o_sqls},
i_dts = List();
For(i_counter = 1, i_counter <= N Items(o_connections), i_counter++,
i_dt = Empty();
i_connection = o_connections[i_counter];
i_sql = o_sqls[i_counter];
query = New SQL Query(Connection(i_connection), Custom SQL(i_sql)) << Run Background(OnRunComplete(i_dt = queryResult));
Insert Into(i_dts, i_dt);
);
Return(i_dts);
);