@@header

/*
*
*  Author     : Vishal Gupta
*  Purpose    : Display view's query
*  Parameters : 1 - OWNER, this could also be passed as OWNER.object_name
*               2 - OBJECT_NAME
*               
*
*  Revision History:
*  ===================
*  Date       Author        Description
*  ---------  ------------  -----------------------------------------
*  25-Feb-13  Vishal Gupta  Created
*
*
*/

/************************************
*  INPUT PARAMETERS
************************************/
UNDEFINE OWNER
UNDEFINE OBJECT_NAME

DEFINE OWNER="&&1"
DEFINE OBJECT_NAME="&&2"



COLUMN  _owner       NEW_VALUE owner          NOPRINT
COLUMN  _object_name   NEW_VALUE object_name      NOPRINT

set term off
SELECT SUBSTR(UPPER('&&owner'), 1 , CASE INSTR('&&owner','.') WHEN 0 THEN LENGTH ('&&owner') ELSE INSTR('&&owner','.') - 1 END ) "_owner"
     , DECODE(UPPER('&&object_name'),'',SUBSTR(UPPER('&&owner'),INSTR('&&owner','.')+1),UPPER('&&object_name')) "_object_name"
FROM DUAL;
set term on


Prompt 
Prompt   ************************************************************
Prompt   ** Object &&OWNER..&&OBJECT_NAME's Source Code
Prompt   ************************************************************


COLUMN text              HEADING "S O U R C E    C O D E"          FORMAT a150

set long 400000
set pages 50000

SELECT s.TEXT
  FROM dba_source s
WHERE s.owner     = '&&OWNER' 
  AND s.name = '&&OBJECT_NAME' 
  ORDER BY s.owner
         , s.name
         , s.type
         , s.line
;


@@footer
