**************************************************************************************
* Description: SQL for Querying Full SQL Text and Session ID via Linux Process Number
* Compatiablity: RDBMS 10g, 11g, 12c
* Date: 17:31 PM EST, 01/09/2017
**************************************************************************************


SQL> prompt "Please Enter The UNIX Process ID"
     set pagesize 50000
     set linesize 30000
     select s.sid,s.serial#,s.sql_id,
     s.username su,
     substr(sa.sql_text,1,1500) txt
     from v$process p,
     v$session s,
     v$sqlarea sa
     where p.addr=s.paddr
     and s.username is not null
     and s.sql_address=sa.address(+)
     and s.sql_hash_value=sa.hash_value(+)
     and spid=&SPID;