/*****************************************************************************
*
* Filename         - $Workfile:   batch_log.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: Bag table and associated items
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 1997
*
*****************************************************************************/

PROMPT Creating table BATCH_LOG

create table batch_log (
   batch_id                      number(10),
   user_id                       number(10),
   function                      varchar2(15),
   flight_id                     number(10)  not null,
   location_code                 varchar2(6) not null,
   scanner_id                    char(6)     not null,
   scan_time                     date        not null,
   bag_tag                       char(10)    not null,
   bag_seq_no                    number(6),
   updated                       char(1) default 'N',
   tag3                          number(10),
   tag2b                         char(3),
   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 batch_log add ( constraint batch_log_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table batch_log add ( constraint batch_log_fk_flight foreign key (flight_id) references flight (flight_id) on delete cascade);

create index batch_log_sk1 on BATCH_LOG(flight_id) tablespace &1._indexes;

COMMENT ON TABLE BATCH_LOG IS 'This table contains batched actions for the scanner';

COMMENT ON COLUMN BATCH_LOG.BAG_SEQ_NO IS  'Bag sequence number';
COMMENT ON COLUMN BATCH_LOG.BAG_TAG IS  'The ten digit bag tag number';
COMMENT ON COLUMN BATCH_LOG.BATCH_ID IS  'Batch identifier';
COMMENT ON COLUMN BATCH_LOG.FLIGHT_ID IS  'The flight identifier';
COMMENT ON COLUMN BATCH_LOG.FUNCTION IS  'Scanner action';
COMMENT ON COLUMN BATCH_LOG.LOCATION_CODE IS  'The location code';
COMMENT ON COLUMN BATCH_LOG.SCANNER_ID IS  'The scanner identifier';
COMMENT ON COLUMN BATCH_LOG.SCAN_TIME IS  'Time the actions were executed on the scanner';
COMMENT ON COLUMN BATCH_LOG.TAG2B IS  'Bag tag carrier number';
COMMENT ON COLUMN BATCH_LOG.TAG3 IS  'Serial number of bag tag';
COMMENT ON COLUMN BATCH_LOG.UPDATED IS  'Action has been applied to the database';
COMMENT ON COLUMN BATCH_LOG.USER_ID IS  'The user identifier';
COMMENT ON COLUMN BATCH_LOG.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN BATCH_LOG.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN BATCH_LOG.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN BATCH_LOG.CUSER IS 'The user who created the row';
COMMENT ON COLUMN BATCH_LOG.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN BATCH_LOG.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN BATCH_LOG.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN BATCH_LOG.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN BATCH_LOG.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
