/*****************************************************************************
*
* Filename         - $Workfile:   system_cfg.sql  $
*
*                     Name              Date      Version     CR Number
* Author           - See revision history below.
* Last Update      - See revision history below.
*
* Project Name     - TAGTRAK(Oracle Database)
*
* Source Code
* Identifier       - 0/3/300/8010/112
*
* Design Spec
* Section          - 
*
* Contents         - Live Schema: system_cfg table and associated items
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 1997
*
*****************************************************************************/

PROMPT Creating table SYSTEM_CFG

create table SYSTEM_CFG (
   PROCESS_NAME                  char(20) NOT NULL,
   UNIT_NAME                     char(10) NOT NULL,
   DCS_STATUS                    char(1) NULL,
   SUBUNIT_NAME                  CHAR(4) NOT NULL,
   BPM_STATUS                    char(1) NULL,
   DCSID                         char(7) NOT NULL,
   DCS_NAME                      char(20) NULL,
   BPM_VERSION                   char(1) NULL,
   BMM_STATUS                    char(1) DEFAULT 'N' NOT NULL,
   RETRY_STATUS                  NUMBER,
   MSGS_THIS_BATCH               NUMBER,
   BNS_STATUS                    char(1) default 'N',
   RP1745                        number(3) null,
   row_create_time               date,
   row_date_time                 date,
   cuser                         varchar2(30),
   muser                         varchar2(30),
   mterm                         varchar2(64),
   source                        varchar2(8),
   to_be_archived                varchar2(1),
   appn_row_id                   number(18) not null,
   system_id                     number(4) default 0 not null
);

alter table system_cfg add ( constraint system_cfg_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table system_cfg add ( constraint system_cfg_uk1 unique (process_name,unit_name,subunit_name,dcsid) using index tablespace &1._indexes);

alter table system_cfg
    add constraint system_cfg_rp1745_chk
	check ((rp1745 is not null and rp1745 > 0) or process_name <>'DCS');

create index SYSTEM_CFG_SK1 on SYSTEM_CFG(PROCESS_NAME) tablespace &1._indexes;

COMMENT ON TABLE SYSTEM_CFG IS 'This table ontains information on various DCS and FIDS that will connect to UltraTrak';

COMMENT ON COLUMN SYSTEM_CFG.BMM_STATUS IS  'BMM status';
COMMENT ON COLUMN SYSTEM_CFG.BPM_STATUS IS  'BPM status';
COMMENT ON COLUMN SYSTEM_CFG.BPM_VERSION IS  'BPM version';
COMMENT ON COLUMN SYSTEM_CFG.DCSID IS  'DCS identifier';
COMMENT ON COLUMN SYSTEM_CFG.DCS_NAME IS  'DCS name';
COMMENT ON COLUMN SYSTEM_CFG.DCS_STATUS IS  'DCS status';
COMMENT ON COLUMN SYSTEM_CFG.MSGS_THIS_BATCH IS  'Number of messages in this batch';
COMMENT ON COLUMN SYSTEM_CFG.PROCESS_NAME IS  'Process name';
COMMENT ON COLUMN SYSTEM_CFG.RETRY_STATUS IS  'Retry status';
COMMENT ON COLUMN SYSTEM_CFG.SUBUNIT_NAME IS  'This can be used along with the SUBUNIT_NAME and DCSID to make a unique identifier';
COMMENT ON COLUMN SYSTEM_CFG.UNIT_NAME IS  'Address stamp of the DCS';
COMMENT ON COLUMN SYSTEM_CFG.RP1745 IS  'The RP1745 edition supported by a DCS';
COMMENT ON COLUMN SYSTEM_CFG.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN SYSTEM_CFG.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN SYSTEM_CFG.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN SYSTEM_CFG.CUSER IS 'The user who created the row';
COMMENT ON COLUMN SYSTEM_CFG.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN SYSTEM_CFG.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN SYSTEM_CFG.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN SYSTEM_CFG.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN SYSTEM_CFG.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
