@@header

/*
*
*  Author        : Vishal Gupta
*  Purpose       : Display DBMS Scheduler Windows
*  Compatibility : 
*  Parameters    : NONE
*
*  Revision History:
*  ===================
*  Date       Author        Description
*  ---------  ------------  -----------------------------------------
*  29-Jun-16  Vishal Gupta  Created
*
*/



/************************************
*  INPUT PARAMETERS
************************************/
UNDEFINE window_group
UNDEFINE window_name
UNDEFINE whereclause

DEFINE window_group="&&1"
DEFINE window_name="&&2"
DEFINE whereclause="&&3"

COLUMN  _window_group        NEW_VALUE  window_group             NOPRINT
COLUMN  _window_name         NEW_VALUE  window_name              NOPRINT

set term off
SELECT DECODE('&&window_group','','%','&&window_group')   "_window_group"
     , DECODE('&&window_name','','%','&&window_name')   "_window_name"
FROM DUAL
/

set term on


PROMPT **************************************************
PROMPT * DBMS Scheduler Windows
PROMPT *   
PROMPT * Input Parameter:
PROMPT *   Window Group   = "&&window_group"
PROMPT *   Window Name    = "&&window_name"
PROMPT **************************************************

COLUMN window_group_name          HEADING  "Window Group"                 FORMAT a20
COLUMN window_name                HEADING  "Window"                      FORMAT a20
COLUMN enabled                    HEADING  "Enabled"                     FORMAT a7
COLUMN active                     HEADING  "Active"                      FORMAT a7
COLUMN window_priority            HEADING  "Window|Priority"             FORMAT a7
COLUMN duration                   HEADING  "Duration"                    FORMAT a11 TRUNC
COLUMN repeat_interval            HEADING  "Repeat Interval"             FORMAT a50
COLUMN number_of_windows          HEADING  "No|of|Win"                   FORMAT 999
COLUMN next_start_date            HEADING  "NextStartDate"               FORMAT a15 
COLUMN Last_start_date            HEADING  "LastStartDate"               FORMAT a15 
COLUMN comments                   HEADING  "Comments"                    FORMAT a60 TRUNC


SELECT wg.window_group_name
     , w.window_name
     , w.enabled
     , w.active
     , w.window_priority
     , w.duration
     , w.repeat_interval
     --, w.manual_open_time
     , TO_CHAR(w.next_start_date,'DD-MON-YY HH24:MI') next_start_date
     , TO_CHAR(w.last_start_date,'DD-MON-YY HH24:MI') last_start_date
     , w.comments
  FROM dba_scheduler_windows w
       JOIN dba_scheduler_wingroup_members wg ON wg.window_name = w.window_name
 WHERE 1=1
   AND wg.window_group_name LIKE '&&window_group'
   AND w.window_name        LIKE '&&window_name'
ORDER BY wg.window_group_name
       , w.next_start_date      
;  

@@footer
