cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
Polyabc
Level II

Closing SQL query after running

Hello,

 

I have a JSL script that calls for different SQL queries. After the data table is complete, I want to close the queries. Is this possible?

 

query = Close( "C:\\example.jmpquery" )

 

does not work.

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
tom_abramov
Level V

Re: Closing SQL query after running

q1 = Open("C:\myQuery.jmpquery");
q1 << Run Foreground;
q1 << Close Window();

View solution in original post

10 REPLIES 10
txnelson
Super User

Re: Closing SQL query after running

See

     Close Database Connection

in the Scripting Index.

I believe that 

Close Database Connection( query );

should work

Jim
Polyabc
Level II

Re: Closing SQL query after running

Thanks!

 

What I want to know if it is possible to close the queries themselves, not necessarily the connection to the database. At the end of the running the script I'm left with 10 open queries which I don't need. Any idea how to close the individual queries?

 

 

Re: Closing SQL query after running

I assume that you mean by 'query' the resulting JMP data tables. If so, then this example should help you.

 

// an open query
 query = Open Database( ... );


// close query
Close( query, No Save );
Polyabc
Level II

Re: Closing SQL query after running

Thanks very much for your reply.

 

I meant the query itself, not the data table. the query that is opened with Select File > New > Database Query.

 

Is there any way to close this query itself?

 

Thanks.

Re: Closing SQL query after running

I do not have an answer. You might take this problem to JMP Technical Support (support@jmp.com).

pmroz
Super User

Re: Closing SQL query after running

I'm not sure what you mean by "closing the query".   How are you seeing these queries as "open"?  I run multiple SQL queries in my applications, and when I'm done I call close database connection, as Jim indicated.  Open tables can be closed with close(<tbl-handle>, nosave) as Mark showed.

This is an example of what I do:

dbc = create database connection("<connection-string>");

sql1 = "SELECT sysdate FROM DUAL";
dt1 = execute sql(dbc, sql1, invisible);

sql2 = "SELECT COUNT(*) FROM all_tables";
dt2 = execute sql(dbc, sql2, invisible);

close database connection(dbc);

Can you share your code?

Polyabc
Level II

Re: Closing SQL query after running

Thanks for your reply.

My code is something like this:

 

query1 = Open( "c:/iris/query1.jmpquery" );
query1 << Run Foreground;

query2 = Open( "c:/iris/query2.jmpquery" );
query2 << Run Foreground;

 

I join the tables that result from these queries, but am left with the open queries themselves.

Any thoughts?

 

pmroz
Super User

Re: Closing SQL query after running

I don't use JMP queries.  You might need to contact tech support.

Totally random stab in the dark - would this do the trick?

query1 = Open( "c:/iris/query1.jmpquery" );
query1 << Run Foreground;
query1 = "";
query2 = Open( "c:/iris/query2.jmpquery" );
query2 << Run Foreground;
query2 = "";
tom_abramov
Level V

Re: Closing SQL query after running

q1 = Open("C:\myQuery.jmpquery");
q1 << Run Foreground;
q1 << Close Window();