@@header

/*
*
*  Author     : Vishal Gupta
*  Purpose    : Display Table/Column Comments
*  Parameters : 1 - owner       (  % as wild card, \ as ESCAPE)
*               2 - table_name  (  % as wild card, \ as ESCAPE)
*               3 - column_name (  % as wild card, \ as ESCAPE)
*                                   
*
*  Revision History:
*  ===================
*  Date       Author        Description
*  ---------  ------------  -----------------------------------------
*  11-May-12  Vishal Gupta  First Draft
*/

DEFINE owner="&&1"
DEFINE table_name="&&2"
DEFINE column_name="&&3"


COLUMN  owner                            HEADING "Table Owner"              FORMAT a20
COLUMN  table_name                       HEADING "Table Name"               FORMAT a30
COLUMN  column_name                      HEADING "Column Name"              FORMAT a30
COLUMN  comments                         HEADING "Comments"                 FORMAT a90


SELECT tc.owner
     , tc.table_name
     , ''  column_name
     , tc.comments
FROM  dba_tab_comments tc
WHERE tc.owner LIKE upper('&&owner') ESCAPE '\'
  AND tc.table_name  LIKE upper('&&table_name') ESCAPE '\'
UNION ALL
SELECT cc.owner
     , cc.table_name
     , cc.column_name
     , cc.comments
FROM  dba_col_comments cc
WHERE cc.owner LIKE upper('&&owner') ESCAPE '\'
  AND cc.table_name  LIKE upper('&&table_name') ESCAPE '\'
  AND cc.column_name  LIKE upper('&&column_name') ESCAPE '\'
ORDER BY 1,2,3 NULLS FIRST
;

  
UNDEFINE owner
UNDEFINE table_name
UNDEFINE column_name

@@footer
