@@header

/*
*
*  Author     : Vishal Gupta
*  Purpose    : Display database links
*  Parameters : 1 - DB Link Owner (Use % as wildcard)
*
*  Revision History:
*  ===================
*  Date       Author        Description
*  ---------  ------------  -----------------------------------------
*  08-Apr-13  Vishal Gupta  Created
*
*/




/************************************
*  INPUT PARAMETERS
************************************/
UNDEFINE owner

DEFINE owner="&&1"



set term off
COLUMN  _owner           NEW_VALUE owner            NOPRINT
SELECT DECODE(UPPER('&&owner'),'','%','&&owner')                   "_owner"
FROM DUAL;
set term on

PROMPT *****************************************************************
PROMPT * D A T A B A S E    L I N K S 
PROMPT * 
PROMPT * Input Parameters 
PROMPT *  - Owner          = '&&owner'
PROMPT *****************************************************************

COLUMN owner          HEADING "Owner"         FORMAT a20
COLUMN db_link        HEADING "DB Link Name"  FORMAT a45
COLUMN created        HEADING "Created"       FORMAT a18
COLUMN username       HEADING "User"          FORMAT a15
COLUMN host           HEADING "Host"          FORMAT a80

SELECT l.owner
     , l.db_link
     , TO_CHAR(l.created,'DD-MON-YY HH24:MI:SS') created
     , l.username
     , l.host
  FROM dba_db_links l
 WHERE owner like '&&owner'
 ORDER BY l.owner
        , l.db_link
;

@@footer