Ottenere un riferimento alla tabella dati da NewSQLQuery() << Esegui Background with Names Default to Here(1);Ho problemi a ottenere il riferimento alla tabella dati se eseguo in background.Qualcuno sa come aggirare questo problema?
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 << Run Background(
OnRunComplete(
dt = queryResult;
dt = data table(queryResult<<GET name=""></GET>
Ri: Ottenere un riferimento alla tabella dati da NewSQLQuery() << Esegui lo sfondo con i nomi predefiniti su Here(1);Un'opzione è utilizzare un nuovo spazio dei nomi per la sottoquery:
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 << Run Background(
OnRunComplete(
ns = namespace( "subquery" );
ns:result = queryResult;
ns:dt = data table ( queryResult << Get Name );
ns:isdone = 1;
)
);
//every second check if the query is done (timeout after 10 seconds)
i=0;
while( ( i < 10 ) & ( 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 );
Modifica: ecco un collegamento a un esempio simile:
https://community.jmp.com/t5/JMP-Scripts/Run-queries-in- background-wait-for-them-to-complete-and/ta-p/274591
Oggetto: Ottenere un riferimento a una tabella dati da NewSQLQuery() << Esegui lo sfondo con i nomi predefiniti su Qui (1);Qualche novità al riguardo. Sto riscontrando lo stesso identico problema!Ri: Risoluzione dei problemi comuni relativi alle tabelle dati con JMP® 13: possiamo sostituire il riepilogo e unirci con il nuovo generatore di query JMP?Ho inserito un bug per supportare.Mi sembra che <
query_complete = 0;
dt_list = {};
dt_array = associative array();
str = "A";
ns = new namespace("Test");
query << 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;
)
);
Ri: Risoluzione dei problemi comuni relativi alle tabelle dati con JMP® 13: possiamo sostituire il riepilogo e unirci con il nuovo generatore di query JMP?Nel mio test non ho aggiunto il file Nomi predefiniti qui(1) - sembra che questa sia la differenza.IL OnRunComplete() la funzione non viene eseguita nello stesso modo Qui namespace come lo script originale.Se crei il tuo spazio dei nomi per conservare i risultati, dovresti essere in grado di accedere alle variabili una volta completata la query.
Ri: Risoluzione dei problemi comuni relativi alle tabelle dati con JMP® 13: possiamo sostituire il riepilogo e unirci con il nuovo generatore di query JMP?Anche se lo faccio.
query_complete = 0;
query << Run Background(
OnRunComplete(
query_complete = 1;
dt = queryResult;
show(dt); //shows correctly for either one
)
);
Sembra che On Run Complete non mi abbia alcun effetto.Se lo eseguo in parti, controllo il valore di query_complete, è ancora 0 anche dopo l'esecuzione dello script Esegui completamento.
Ri: Risoluzione dei problemi comuni relativi alle tabelle dati con JMP® 13: possiamo sostituire il riepilogo e unirci con il nuovo generatore di query JMP?L'aggiunta di wait(1) non fa funzionare il secondo show(dt).Questo è il problema.Non è possibile trovare un riferimento alla tabella dati da una query SQL eseguita in background.
Ri: Risoluzione dei problemi comuni relativi alle tabelle dati con JMP® 13: possiamo sostituire il riepilogo e unirci con il nuovo generatore di query JMP?Forse non capisco, ma penso che questo dimostri perché hai bisogno dello script <
Se aggiungi un Wait(1) tra la chiamata <