/*MAIN
 Overview

 W_ACTION_CS_02 is a procedure that contains the necessary steps to take
    when within a conseq, there is no unpacked major frame datetime and
    two or more unpacked major frame counters.  This state is represented 
    by the last two characters in the name of the procedure (02).  W_ACTION_CS_02 
    is stored as a VARCHAR2 action item in table CS_LOOKUPT, table which 
    contains all the other actions to take depending on the state of the conseq.
MAIN*/

/*ARGUMENTS
  Arguments

  W_ACTION_CS_02 takes the following arguments, all of which have an IN
  parameter mode:
   - NEW_ID1 (INTEGER).  This variable represents the lower boundary of the
     conseq in examination.

   - NEW_ID2 (INTEGER).  This variable represents the upper boundary of the
     conseq in examination.  Note that NEW_ID2 is not included in the conseq.

   - GFST (VARCHAR2).  This variable represents the Good Frames Statistics
     Table that was posted by Labview just prior to the onset of reconstruction.

   - BFST (VARCHAR2).  This variable represents the Bad Frame statistics Table
     that was posted by Labview just prior to the onset of reconstruction.

   - NUM_DT (INTEGER).  This variable represents the number of distinct not
     null floating point datetimes present in the conseq, with no Minor Frame
     Failing Flag (MNFFF) or date error (DATEERR) flag raised in the BFST.

   - NUM_UMFC (INTEGER).  This variable represents the number of distinct not
     null major frame counter present in the conseq, with no Minor Frame
     Failing Flag (MNFFF) raised in the BFST.
ARGUMENTS*/

/*DEPENDENCIES
 Dependencies

 The following are the programs called by W_ACTION_CS_02:
   - W_BFST_CALC_TIME_GRT.  This procedure computes the major frame
     floating point datetime in the conseq based on the floating point
     ground receipt datetime.

   - W_BFST_CALC_TIME_UMFC.  This procedure computes the major frame
     floating point datetime in the conseq based on the unpacked major 
     frame counter.
     
   - W_BFST_GRTvsUMFC.  This procedure compared the major frame floating
     point datetime computed based on the ground receipt time, versus the
     major frame floating point datetime computed based on the unpacked
     major frame counter.
     
   - DBMS_SQL.  This the native Oracle dynamic SQL package;

   - OPEN_AND_PARSE.  This function combines what would otherwise have
     been separate calls to the native Oracle DBMS_SQL.OPEN_CURSOR and
     DBMS_SQL.PARSE procedures, into a single function.

   - EXECUTE_AND_CLOSE.  This function combines what would otherwise have
     been separate calls to the native Oracle DBMS_SQL.EXECUTE and
     DBMS_SQL.CLOSE procedures, into a single function.

   - DBMS_OUTPUT.PUT_LINE.  This native oracle package writes to the
     buffer.
DEPENDENCIES*/

/*VARIABLES
 Variables

 The followind are variables used in the procedure:
   - C (INTEGER). Cursor handle.

   - DATETIME_GRT (NUMBER).  Major frame floating point datetime
     computed based on the minor frame floating point ground recept datetime.

   - DATETIME_UMFC (NUMBER).  Major frame floating point datetime
     computed based on the unpacked major frame counter present in the conseq.

   - EXECUTE1 (INTEGER).  The number of rows processed by the SQL statement
     if that statement is an UPDATE, INSERT, or DELETE.  If the SQL statement is
     not an UPDATE, INSERT, or DELETE, this value should be ignored.
     
   - DISC1 (INTEGER).  The value of the discontinuity in this conseq.

   - UMFC1, UMFC2 and UMFC3 (INTEGER).  The values of major frame counters 
     unpacked in this conseq.  The two UMFCs in the conseq are extracted 
     into UMFC1 and are in turn assigned to UMFC2 and UMFC3. 

   - RULE (VARCHAR2(20)).  The name of the current procedure.  This variable will
     be supplied to procedure W_BFST_GRTvsUMFC so as to identify in the output
     messages, under what state of the conseq W_BFST_GRTvsUMFC was invoked.
   
   - NUM_UMFC2 (INTEGER).  A count of the number of minor frames that have an 
     unpacked major frame counter of UMFC2.

   - NUM_UMFC3 (INTEGER).  A count of the number of minor frames that have an 
     unpacked major frame counter of UMFC3.

   - LOOP_ENTRY (INTEGER).  A variable used to initialize the entry in the
     loop where the two major frame counters present in this conseq will be
     extracted into two local variables (UMFC2 and UMFC3).
 
   - COUNT1 (INTEGER).  The number of distinct not null major frame counter
     present in the conseq, with no Minor Frame Failing Flag (MNFFF) raised
     in the BFST.
VARIABLES*/

/*EXAMPLES
 Examples

 Here is a call to W_ACTION_CS_02

   BEGIN
       W_ACTION_CS_02 (1, 100, WINDxxxGOOD, WINDyyyBAD, 0,0);
   END;
   /

 The arguments for this procedure are passed in from procedure 
   W_BFST_FILL_TIMES.
EXAMPLES*/

/*EXCEPTIONS
 Exceptions
 
 There are no named exceptions for this procedure, execpt for the generic one
 WHEN OTHERS.  When the latter is triggered, the error message is outputed
 along with the name of the module that erred, and any cursors that may still
 be opened are closed
EXCEPTIONS*/

/*ERRORS
 Errors

 There are no errors that this procedure is known to generate.
 Should an error occur, take action based on the description
 of the error.
ERRORS*/

/*TABLES
 Tables

 The following tables are referenced in this procedure:
  - GFST.  This is the Good Frames Statistics Table that was posted by
    Labview just prior to the onset of reconstruction.

  - BFST.  This is the Bad Frame statistics Table that was posted by Labview
    just prior to the onset of reconstruction.

  - UNIQUE_UMFC.  This is a temporary table that is created and dropped by 
    procedure W_BFST_FILL_TIMES.  It contains all the distinct not null   
    unpacked major frame counters that are present in the BFST from minor
    frames with MNFFF (Minor Frame Fail Flag) = FALSE. 

 For more information on these and other tables, see (xxx).
TABLES*/

/*OTHERS
 Others
 
 It should be noted that when procedure W_BFST_CALC_TIME_GRT returns
    a value of DATETIME_GRT = 0, this means that the floating point
     major frame datetime could not be determined from the minor frame 
    ground receipt datetime.  If the latter be true, procedure
    W_BFST_CALC_TIME_GRT will alert the analyst to this situation.
 
 When procedure W_BFST_CALC_TIME_UMFC returns a value of DATETIME_UMFC = 0,
    this means that the floating point major frame datetime could not be 
    determined from the major frame counter unpacked in the conseq.  If
    the latter be true, procedure W_BFST_CALC_TIME_UMFC will alert the
    analyst to this situation.

 When DATETIME_GRT = 0 and DATETIME_UMFC = 0, procedure W_BFST_GRTvsUMFC
    will alert the analyst as to the state of the conseq and proceed with
    reconstrution without filling the major frame floating point datetime
    column in the conseq.
 
 Note that the resulting UMFC in the conseq is also filled in the minor frames
    where it has not been unpacked because in the system state where there is
    no Good Frame Statistics Table but there is a Bad Frame Statistics Table,
    this filled UMFC is used by Oracle to identify the major frame to which
    the minor frames belong.

 It should be noted that in this procedure, if there are more than two
   unpacked major frame counters in a conseq, the analysts will be
   alerted and no filling of the times will be done because this state
   is currently not being handled.

 For more details on this procedure see WIND_RECONSTRUCTION.
OTHERS*/
