/*****************************************************************************
*
* Filename         - $Workfile:   batch_actions.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: batch_actions table and associated items
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 1997
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   batch_actions.sql  $  $Revision:   1.2  $
*
* Revision History
*
* Note that user tagtrak is many users. For these users the user
* name is entered as the last line in the change description.
*
* $Log:
*
*
****************************************************************************/
 

PROMPT Creating table BATCH_ACTIONS

create table batch_actions (
   function                      varchar2(15),
   flight_id                     NUMBER(10)   NOT NULL,
   LOCATION_CODE                 varchar2(6),    
   upload_time                   date default SYSDATE,
   posn                          varchar2(6),   
   scanner_id                    char(6),
   USER_ID                       number(10) ,
   scan_time                     date   NOT NULL,
   bag_tag                       char(10),
   ufid                          number(10),
   uld_destination               char(3),
   ULD_CLASS_LIST                CHAR(10), 
   ULD_CATEGORY                  varchar2(5) ,
   uld_no                        char(10),
   uld_no_to                     char(10), 
   updated                       char(1) default 'N', 
   uld_onwards_flt               varchar2(8),
   uld_onwards_date              varchar2(5),
   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_actions add ( constraint batch_actions_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table batch_actions add ( constraint batch_actions_fk_flight foreign key (flight_id) references flight (flight_id) on delete cascade);

create index batch_actions_sk1 on BATCH_ACTIONS(flight_id) tablespace &1._indexes;

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

COMMENT ON COLUMN BATCH_ACTIONS.BAG_TAG IS  'The ten digit bag tag number';
COMMENT ON COLUMN BATCH_ACTIONS.FLIGHT_ID IS  'The flight identifier';
COMMENT ON COLUMN BATCH_ACTIONS.FUNCTION IS  'Scanner action';
COMMENT ON COLUMN BATCH_ACTIONS.LOCATION_CODE IS  'Location code';
COMMENT ON COLUMN BATCH_ACTIONS.POSN IS  'ULD position';
COMMENT ON COLUMN BATCH_ACTIONS.SCANNER_ID IS  'Scanner identifier';
COMMENT ON COLUMN BATCH_ACTIONS.SCAN_TIME IS  'Time the actions were executed on the scanner';
COMMENT ON COLUMN BATCH_ACTIONS.UFID IS  'ULD identifier';
COMMENT ON COLUMN BATCH_ACTIONS.ULD_CATEGORY IS  'The ULD category';
COMMENT ON COLUMN BATCH_ACTIONS.ULD_CLASS_LIST IS  'The class list for the ULD';
COMMENT ON COLUMN BATCH_ACTIONS.ULD_DESTINATION IS  'The destination of the ULD';
COMMENT ON COLUMN BATCH_ACTIONS.ULD_NO IS  'The ULD number';
COMMENT ON COLUMN BATCH_ACTIONS.ULD_NO_TO IS  'The ULD number';
COMMENT ON COLUMN BATCH_ACTIONS.UPDATED IS  'Y indicates the action was applied to the database N indicates it hasn.t been applied yet';
COMMENT ON COLUMN BATCH_ACTIONS.UPLOAD_TIME IS  'Time the action was sent to the database';
COMMENT ON COLUMN BATCH_ACTIONS.USER_ID IS  'The user identifier';
COMMENT ON COLUMN BATCH_ACTIONS.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN BATCH_ACTIONS.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN BATCH_ACTIONS.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN BATCH_ACTIONS.CUSER IS 'The user who created the row';
COMMENT ON COLUMN BATCH_ACTIONS.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN BATCH_ACTIONS.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN BATCH_ACTIONS.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN BATCH_ACTIONS.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN BATCH_ACTIONS.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
