<?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: Solving Common Data Table Problems With JMP® 13: Can We Replace Summary and Join With the New JMP Query Builder? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/187266#M40594</link>
    <description>&lt;P&gt;Even if I do this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;
query_complete = 0;
query &amp;lt;&amp;lt; Run Background(
	OnRunComplete(
		query_complete = 1;
		dt = queryResult;
		show(dt); //shows correctly for either one
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It seems like On Run Complete doesn't affect me.&amp;nbsp; If I run it it in parts then check the value of query_complete, it's still 0&amp;nbsp; even after the Run complete script is run.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Mar 2019 17:19:08 GMT</pubDate>
    <dc:creator>vince_faller</dc:creator>
    <dc:date>2019-03-15T17:19:08Z</dc:date>
    <item>
      <title>Getting a data table reference from NewSQLQuery() &lt;&lt; Run Background with Names Default to Here(1);</title>
      <link>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/187001#M40556</link>
      <description>&lt;P&gt;I'm having trouble getting the data table reference if I run in the background.&amp;nbsp; Anyone know how to get around this?&amp;nbsp;&amp;nbsp;&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);

sql_query = New SQL Query(
	Connection(
		"ODBC:DSN=Test Source;DATABASE=Test;"
	),
	QueryName( "Thingy" ),
	Select(
		blah
	),
	From(
		other blah
	)
);

sql_query &amp;lt;&amp;lt; Run Background(
	OnRunComplete(
		dt = queryResult;
		dt = data table(queryResult&amp;lt;&amp;lt;Get Name);
		show(dt); //shows correctly for either one
	)
);

show(dt); // it seems like on run complete is local&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Mar 2019 15:26:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/187001#M40556</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2019-03-18T15:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: Solving Common Data Table Problems With JMP® 13: Can We Replace Summary and Join With the New JMP Query Builder?</title>
      <link>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/187085#M40562</link>
      <description>&lt;P&gt;Maybe I'm not understanding, but I think this shows why you need the &amp;lt;&amp;lt;OnRunComplete() script.&amp;nbsp; When run in the background, control returns immediately and the data table does not exist yet.&amp;nbsp; So you will get an error if you try to use dt before it is created.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you add a Wait(1) between the &amp;lt;&amp;lt;RunBackground() call and the second Show(dt) message, I think both Show() commands will succeed.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 20:27:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/187085#M40562</guid>
      <dc:creator>danschikore</dc:creator>
      <dc:date>2019-03-14T20:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Solving Common Data Table Problems With JMP® 13: Can We Replace Summary and Join With the New JMP Query Builder?</title>
      <link>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/187264#M40592</link>
      <description>&lt;P&gt;Adding the wait(1) does not make the second show(dt) work.&amp;nbsp; That's the problem.&amp;nbsp; There is no way I can find to get a data table reference from a sql query run in the background.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2019 17:15:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/187264#M40592</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2019-03-15T17:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: Solving Common Data Table Problems With JMP® 13: Can We Replace Summary and Join With the New JMP Query Builder?</title>
      <link>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/187266#M40594</link>
      <description>&lt;P&gt;Even if I do this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;
query_complete = 0;
query &amp;lt;&amp;lt; Run Background(
	OnRunComplete(
		query_complete = 1;
		dt = queryResult;
		show(dt); //shows correctly for either one
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It seems like On Run Complete doesn't affect me.&amp;nbsp; If I run it it in parts then check the value of query_complete, it's still 0&amp;nbsp; even after the Run complete script is run.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2019 17:19:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/187266#M40594</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2019-03-15T17:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Solving Common Data Table Problems With JMP® 13: Can We Replace Summary and Join With the New JMP Query Builder?</title>
      <link>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/187277#M40597</link>
      <description>&lt;P&gt;In my test I did not add the &lt;FONT face="courier new,courier"&gt;Names Default To Here(1)&lt;/FONT&gt; - it looks like that is the difference.&amp;nbsp; The &lt;FONT face="courier new,courier"&gt;OnRunComplete()&lt;/FONT&gt; function is not running in the same &lt;FONT face="courier new,courier"&gt;Here&lt;/FONT&gt; namespace as the original script.&amp;nbsp; If you create your own namespace to hold the results, you should be able to access the variables after the query completes.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2019 18:00:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/187277#M40597</guid>
      <dc:creator>danschikore</dc:creator>
      <dc:date>2019-03-15T18:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: Solving Common Data Table Problems With JMP® 13: Can We Replace Summary and Join With the New JMP Query Builder?</title>
      <link>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/187301#M40602</link>
      <description>&lt;P&gt;I put in a bug to support.&amp;nbsp; It looks to me like &amp;lt;&amp;lt;Run Background has its own here namespace that is separate and unable to communicate with mine.&amp;nbsp; Notice how the value doesn't show the first time, but once it has run the query remembers it's value set.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;query_complete = 0;
dt_list = {};
dt_array = associative array();
str = "A";
ns = new namespace("Test");
query &amp;lt;&amp;lt; Run Background(
	OnRunComplete(
		try(show(query_complete)); //this won't show, but if you run it twice it will show as 1
		try(show(dt_list));
		try(show(dt_array));
		try(show(str));
		try(show(ns));
		try(show(namespace("Test")));
		
		query_complete = 1;
	)
);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Mar 2019 19:40:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/187301#M40602</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2019-03-15T19:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a data table reference from NewSQLQuery() &lt;&lt; Run Background with Names Default to Here(1);</title>
      <link>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/224505#M44622</link>
      <description>Any news on this. I'm running into the very same problem!</description>
      <pubDate>Tue, 03 Sep 2019 20:07:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/224505#M44622</guid>
      <dc:creator>Phil_Brown</dc:creator>
      <dc:date>2019-09-03T20:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a data table reference from NewSQLQuery() &lt;&lt; Run Background with Names Default to Here(1);</title>
      <link>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/224647#M44648</link>
      <description>&lt;P&gt;One option is to use a new namespace for the subquery:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

// Namespace to share data between background query and this script
ns = new namespace( "subquery" );

// The background query will set to 1 when the background query is complete
ns:isdone = 0;

sql_query = New SQL Query(
	Connection( "ODBC:DSN=Test Source;DATABASE=Test;" ),
	QueryName( "Thingy" ),
	Select( blah ),
	From( other blah )
);

sql_query &amp;lt;&amp;lt; Run Background(
	OnRunComplete(
		ns = namespace( "subquery" );
		ns:result = queryResult;
		ns:dt = data table ( queryResult &amp;lt;&amp;lt; Get Name );
		ns:isdone = 1;
	)
);

//every second check if the query is done (timeout after 10 seconds)
i=0;
while( ( i &amp;lt; 10 ) &amp;amp; ( ns:isdone == 0 ) ,
	i++;
	if( ns:isdone == 1, show( ns:dt ), show( "Query not done yet." ); wait( 1 ); );
);

//now you can reference the data table
show( ns:dt );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Edit: Here is a link to a similar example:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/t5/JMP-Scripts/Run-queries-in-background-wait-for-them-to-complete-and/ta-p/274591" target="_blank"&gt;https://community.jmp.com/t5/JMP-Scripts/Run-queries-in-background-wait-for-them-to-complete-and/ta-p/274591&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2020 12:10:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/m-p/224647#M44648</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2020-06-22T12:10:32Z</dc:date>
    </item>
  </channel>
</rss>

