@@header

/*
*
*  Author     : Vishal Gupta
*  Purpose    : Display Session Details
*  Parameters : 1 - SPID    (OS Process ID)
*               2 - INST_ID (optional, default to 1)
*
*  Revision History:
*  ===================
*  Date       Author        Description
*  ---------  ------------  -----------------------------------------
*  05-Aug-04  Vishal Gupta  First Draft
*/


VARIABLE SID NUMBER;
VARIABLE SPID NUMBER;
VARIABLE INST_ID NUMBER;

BEGIN
    :SPID := '&&1';
 :INST_ID := NVL('&&2',1);
 IF :INST_ID = '' OR :INST_ID IS NULL THEN
    :INST_ID := 1;
 END IF; 
EXCEPTION
   WHEN NO_DATA_FOUND THEN
      NULL;
END;
/


UNDEFINE SID
UNDEFINE INST_ID

COLUMN col1 new_value SID      NOPRINT
column col2 new_value INST_ID  NOPRINT

    SELECT S.SID     COL1
         , S.INST_ID COL2
     FROM GV$SESSION S, GV$PROCESS P
    WHERE S.INST_ID = P.INST_ID
      AND   S.PADDR = P.ADDR
      AND   P.SPID = :SPID
      AND   P.INST_ID = :INST_ID
    ;

@@sid_details &&SID &&INST_ID

