<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to run multiple SQL queries in parallel, wait for fnish, and get list of datatables in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-run-multiple-SQL-queries-in-parallel-wait-for-fnish-and/m-p/717150#M89881</link>
    <description>&lt;P&gt;Unfortunately JMP only provides a single execution thread for JSL.&amp;nbsp; For my company I get around this limitation and do exactly what you're wanting to do by using a persistent Python session.&amp;nbsp; I launch the Python session from JMP, which has a hook for when the STDOUT buffer is not empty, and in Python I start a localhost server and wait for commands.&amp;nbsp; Then in JMP I can connect to the localhost server and send messages.&amp;nbsp; Python will then, in parallel, complete the assigned tasks (whether it's SQL or file-transfers or anything needed) and have special print statements for when complete, thus closing the loop and allowing JMP to know when the queries are completed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For SQL I have Python save the results in a temporary file then JMP can simply read the file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is a little round-about, but not too much more difficult than if JMP provided a means for concurrency or asynchronous execution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works quite well and the slowdown due to IPC is not noticeable.&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jan 2024 23:06:07 GMT</pubDate>
    <dc:creator>ErraticAttack</dc:creator>
    <dc:date>2024-01-15T23:06:07Z</dc:date>
    <item>
      <title>How to run multiple SQL queries in parallel, wait for fnish, and get list of datatables</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-run-multiple-SQL-queries-in-parallel-wait-for-fnish-and/m-p/717014#M89867</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Run_SQL_Queries = Function({o_connections, o_sqls},  
	i_dts = List();

	For(i_counter = 1, i_counter &amp;lt;= 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)) &amp;lt;&amp;lt; Run Background(OnRunComplete(i_dt = queryResult));
		Insert Into(i_dts, i_dt);
	);
	Return(i_dts);
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 15 Jan 2024 09:30:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-run-multiple-SQL-queries-in-parallel-wait-for-fnish-and/m-p/717014#M89867</guid>
      <dc:creator>UEJ</dc:creator>
      <dc:date>2024-01-15T09:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to run multiple SQL queries in parallel, wait for fnish, and get list of datatables</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-run-multiple-SQL-queries-in-parallel-wait-for-fnish-and/m-p/717025#M89868</link>
      <description>&lt;P&gt;I'm not sure if you can build such a function in JMP. You might have to use &amp;lt;&amp;lt; OnRunComplete within your &amp;lt;&amp;lt; Run Background and perform whatever you are doing, after all queries are ready, using that.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 09:39:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-run-multiple-SQL-queries-in-parallel-wait-for-fnish-and/m-p/717025#M89868</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-01-15T09:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to run multiple SQL queries in parallel, wait for fnish, and get list of datatables</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-run-multiple-SQL-queries-in-parallel-wait-for-fnish-and/m-p/717150#M89881</link>
      <description>&lt;P&gt;Unfortunately JMP only provides a single execution thread for JSL.&amp;nbsp; For my company I get around this limitation and do exactly what you're wanting to do by using a persistent Python session.&amp;nbsp; I launch the Python session from JMP, which has a hook for when the STDOUT buffer is not empty, and in Python I start a localhost server and wait for commands.&amp;nbsp; Then in JMP I can connect to the localhost server and send messages.&amp;nbsp; Python will then, in parallel, complete the assigned tasks (whether it's SQL or file-transfers or anything needed) and have special print statements for when complete, thus closing the loop and allowing JMP to know when the queries are completed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For SQL I have Python save the results in a temporary file then JMP can simply read the file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is a little round-about, but not too much more difficult than if JMP provided a means for concurrency or asynchronous execution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works quite well and the slowdown due to IPC is not noticeable.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 23:06:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-run-multiple-SQL-queries-in-parallel-wait-for-fnish-and/m-p/717150#M89881</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2024-01-15T23:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to run multiple SQL queries in parallel, wait for fnish, and get list of datatables</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-run-multiple-SQL-queries-in-parallel-wait-for-fnish-and/m-p/717151#M89882</link>
      <description>&lt;P&gt;I've been doing something similar for a while.&amp;nbsp; I run multiple queries simultaneously and then perform operations on the tables.&amp;nbsp; I have adapted my solution for your application.&amp;nbsp; It's not pretty, but I have tried many, many other ways in JMP, and nothing else has accomplished what I wanted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
o_connections = {....Connection List....};
o_sqls = {....Query List....};
::i_dts = {};
Run_SQL_Queries = Function( {o_connection, o_sql, i_counter},
	{Default Local},
	Eval(
		Eval Expr(
			Expr(
				Parse( "::i_dt" || Char( i_counter ) || " = Empty()" )
			);
			New SQL Query( Connection( o_connection ), Custom SQL( o_sql ) ) &amp;lt;&amp;lt; Run Background(
				OnRunComplete(
					Expr(
						Parse( "::i_dt" || Char( i_counter ) || " = QueryResult;" )
					);
					Insert Into( ::i_dts, QueryResult )
					;
				)
			);
		)
	)
);
For( i=1, i&amp;lt;=N Items(o_connections), i++, Run_SQL_Queries( o_connections[i], o_sqls[i], i ) );
For( i = 1, i &amp;lt;= N Items( o_connections ), i++,
	Eval( Parse( "While(!Is Scriptable(::i_dt" || Char( i ) || "), Wait(.5))" ) )
);
Show( ::i_dt1, ::i_dt2, ::i_dts );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Jan 2024 23:59:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-run-multiple-SQL-queries-in-parallel-wait-for-fnish-and/m-p/717151#M89882</guid>
      <dc:creator>mmarchandTSI</dc:creator>
      <dc:date>2024-01-15T23:59:22Z</dc:date>
    </item>
  </channel>
</rss>

