Tuesday, 6 June 2017

Cancel Concurrent Programs Requests from Backend


Use the below block to kill the session for Concurrent program request which will cancel the concurrent program.


DECLARE
   l_sid      NUMBER;
   l_serial   NUMBER;
   l_req_id   NUMBER := &request_id;
BEGIN
   SELECT sid, serial#
     INTO l_sid, l_serial
     FROM v$session
    WHERE paddr LIKE
             (SELECT addr
                FROM v$process
               WHERE spid = (SELECT oracle_process_id
                               FROM fnd_concurrent_requests
                              WHERE request_id = l_req_id));

   DBMS_OUTPUT.PUT_LINE (
         'ALTER SYSTEM KILL SESSION '
      || ''''
      || l_sid
      || ','
      || l_serial
      || '''');

   EXECUTE IMMEDIATE
         'ALTER SYSTEM KILL SESSION '
      || ''''
      || l_sid
      || ','
      || l_serial
      || '''';
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      DBMS_OUTPUT.PUT_LINE ('Session not found ' || SQLERRM);
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.PUT_LINE (' When others error ' || SQLERRM);
END;

No comments:

Post a Comment