I have to parallelly execute several queries in SAS, using Rsubmit. Since I can run just 3 queries at a time, I have to ensure that the 4th query runs only any 1(of the 3) is completed. Can I use a rsubmit block after the waitfor option?
Here is a sample I want to execute, asynchronously,
option autosignon=yes;
options sascmd="sas";
rsubmit process= task1 wait=no;
#Task1 is entered here
endrsubmit;
rsubmit process= task2 wait=no;
#Task2 is entered here
endrsubmit;
rsubmit process= task3 wait=no;
#Task3 is entered here
endrsubmit;
waitfor _any_;
rsubmit process= task4 wait=no;
#Task4 is entered here
endrsubmit;
waitfor _any_;
rsubmit process= task5 wait=no;
#Task5 is entered here
endrsubmit;
I am unsure whether the waitfor option will work as expected.
Did you try running the code using waitfor _any_ ? It should work.
Related
PROC SQL; UPDATE CLEAN.Unknown_Provs AS A SET ProviderAddress1=(SELECT COALESCEC(Prac1stAddr,Mail1stAddr) FROM HED.tblProviderNPI AS B WHERE A.UnknownFile_ProviderKey=B.NPI) WHERE ProviderAddress1=''; quit;
HED is the libname created for the SQL server database.
How can i fix the error
My serverless redshift has thousands of running queries. I think it is stuck. I'm not sure how to cancel all queries and start fresh. Is there a way to do it?
Since STV_RECENTS is not available in serverless endpoint, you can get all the running queries with
SELECT * FROM SYS_QUERY_HISTORY WHERE status = 'running'
, the session_id is the PID
Then you can cancel them with
CANCEL <session_id>
From CANCEL - Amazon Redshift:
Cancels a database query that is currently running.
CANCEL process_id [ 'message' ]
The CANCEL command requires the process ID of the running query and displays a confirmation message to verify that the query was cancelled.
To cancel a currently running query, first retrieve the process ID for the query that you want to cancel. To determine the process IDs for all currently running queries, type the following command:
select pid, starttime, duration,
trim(user_name) as user,
trim (query) as querytxt
from stv_recents
where status = 'Running';
See also:
PG_TERMINATE_BACKEND - Amazon Redshift that terminates a session
Terminate (kill) specific session on a server - Amazon Redshift Data Dictionary Queries
I am using ajax to run a django function. In this function, I connect to the database and run a sql statement, the result of which is saved to a csv file. This sql takes a long time to run at times, and I would like to be able to interrupt this function on demand. Is it possible? Can I get the id of the running process or request and use it to kill it?
Scenario:
I run SAS programs from Sasfusion server abc123.
I run regular SAS programs with proc contents, proc prints, proc exports, etc with no issue.
I was just requested to access a SAS dataset in location on a separate server zyx123 (not sure if it is Sasfusion or not)
I thought this would be something simple like putting in a libname statement.
libname z '\path to the folder\' server=zyx123;
proc contents data = z.requesteddataset;
run;
Is it possible to even do the above?
I get the following errors:
ERROR: Libref TEST is not assigned.
ERROR: Error in the LIBNAME statement.
ERROR 23-7: Invalid value for the SERVER option.
The LIBNAME option SERVER= is used to access to data sets on a machine with SAS/SHARE licensed running a SAS session in which Proc SERVER is executing.
See the SAS/SHARE User's Guide, LIBNAME documentation:
LIBNAME Statement
In a client session, associates a libref (a shortcut name) with a SAS library that is located on the server for client access. In a server session, predefines a server library that clients are permitted to access.
…
SERVER=<server-node.>server-name | __port-number
specifies the location and identity of the SAS/SHARE server session that administers the SAS library.
You should request additional information about the remote server from you network / SAS administrator.
Not sure about your specific ERROR messages logged -- the log for an unsuccessful libname (on my machine) looks like:
12 libname foo 'c:\temp' server=#######.######;
ERROR: Attempt to connect to server #######.###### failed.
ERROR: A communication subsystem partner link setup request failure has occurred.
ERROR: The connection was refused.
ERROR: Error in the LIBNAME statement.
If I submit a series of SQL statements (each with GO in sqlcmd) that I want to make an reasonable attempt to run on an Azure SQL Data Warehouse, I've found in sqlcmd how to ignore errors. But I've seen if I want to abort a statement in that sequence of statements with:
KILL "SIDxxxxxxx";
The whole session ends:
Msg 111202, Level 16, State 1, Server adws_database, Line 1
111202;Query QIDyyyyyyyyyy has been cancelled.
Is there a way to not end a query session in Azure SQL Data Warehouse? Similar to how postgres's
pg_cancel_backend()
works?
In postgres the
pg_terminate_backed(<pid>)
seems to be working similarly to the ADW
KILL 'SIDxxxx'
command.
Yes, a client can cancel a running request without aborting the whole session. In SSMS this is what the red square does during query execution.
Sqlcmd doesn't expose any way to cancel a running request, though. Other client interfaces do, like the .NET SqlClient you can use SqlCommand.Cancel()
David