/*MAIN
 Overview

 TREND_GEN_RECIPE2 is a sub-procedure that is called by procedure TREND_GEN_
    RECIPE to generate a recipe during trending should there be a need to
    reconstruct major frames within a timespan.
MAIN*/

/*ARGUMENTS
  Arguments

  TREND_GEN_RECIPE2 takes the folling arguments, all of which have an IN
  parameter mode execpt for NMFIRT which has an OUT parameter mode.
   - SUBTABLE (VARCHAR2).  This represents the name of the table which
     contains the BFST pointers for a range of minor frames for all major 
     frames.

   - LOW_INDEX (NUMBER). This represents the lowest minor frame counter
     in the range of minor frames stored in a subtable.

   - HIGH_INDEX (NUMBER). This represents the highest minor frame counter
     in the range of minor frames stored in a subtable.

   - LIM_QRANK1 (NUMBER).  This represents the limit quality rank, which
     sets the boundary from where minor frames will be filled.

   - MAX_QRANK1 (NUMBER).  This represents the maximum quality rank that
     a minor frames can have.

   - NMFIRT (INTEGER).  This represents the Number of Major Frames in the
     Recipe2 Table.
ARGUMENTS*/

/*DEPENDENCIES
 Dependencies

 The following are the sub-programs called by TREND_GEN_RECIPE2:
   - 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, D, E (INTEGER).  Cursor handles.
   
   - FP_UMF_DATETIME1 (NUMBER). The floating point datetime for the major
     frame to be reconstructed.

   - 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.
   
   - ROWID1 (ROWID).  The rowid of the major frame floating point datetime  
     stored in one of these subtables (MNFLT1, MNFLT2, MNFLT3, MNFLT4,
     MNFLT5).

   - COUNT1 (INTEGER).  A running count of the number of major frames that
     are reconstructed.

   - QUALITY1 (INTEGER).  The quality of the minor frames in the recipe2
     table.

   - POINTER1 (NUMBER).  A pointer to which bad frame statistics table minor  
     frames of a major frame may be found.
   
   - MNF_LOC1 (INTEGER).  A pointer to the location of a minor frame in the
     annotated minor frame file.

   - NEW_FILE1 (VARCHAR2(23)).  The name of the bad frames statistics table
     where minor frames of a major frame may be found.

   - NEW_UMFC1 (NUMBER).  The major frame counter of the major frame to be
     reconstructed.  
VARIABLES*/

/*EXAMPLES
 Examples

 Here is a call to TREND_GEN_RECIPE2

   BEGIN
       TREND_GEN_RECIPE ('MNFLT1', 0  , 50 , LIM_QRANK1, MAX_QRANK1, NMFINR);
   END;
   /

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.
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:
  - RECIPE2.  Contains the recipe generated by a trending session.
  
  - SUBTABLE.  Any of the following five tables which contain pointers for
    all major frames' minor frame counters ranging cummulatively from 0 to
    249: MNFLT1, MNFLT2, MNFLT3, MNFLT4, MNFLT5.

  - TREND_TIME.  Contains major frames floating point datetimes and their
    associated counters, for which a trending session requests that a 
    recipe be generated.
  
  - MNFFPT.  This is the minor frame file pointer table which store the
    actual file names that are pointed to in the above mentioned five
    subtables.

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

/*OTHERS
 Others
 
 It should be noted that this sub-procedure is called five times by procedure 
    TREND_GEN_RECIPE , each time corresponding to a different minor frame
    pointer table (MNFLTx) and its associated range of minor frames.

 For more details on this procedure see the section on TRENDING in file
 RECONSTRUCTION.txt.
OTHERS*/
