Sage-ST ä

Dbload

Documentation

Global Declarations (Constants, Types, Variables)
LoadDBaseIIIFormat LoadDIFFormat LoadDelimitedFormat
LoadDumpFormat LoadSDFFormat LoadSDIFormat QuickLoadSDF
UnloadDBaseIIIFormat UnloadDIFFormat UnloadDelimitedFormat UnloadDumpFormat
UnloadSDFFormat UnloadSDIFormat





  (**
      DBLoad - Loading and unloading data in various formats.

      LoadDef =
        RECORD
        relation : ARRAY [0 .. 7] OF CHAR; -- name of relation
        field : ARRAY [0 .. 7] OF CHAR;    -- name of field
        repeat : CARDINAL;                 -- field repeat number 1 .. n
        startIndex : CARDINAL;             -- field start position (1 .. n)
        END;

      * Note two important things about the LoadDef record.

      1) The StartIndex field is only used by the SDF Format routine.
         For all other formats this can be initially set to 0.          -- any values in this field.

      2) There is a special case for the relation and field name.
         Setting BOTH of these names to the value "NULL" will cause this
         field to be skipped.  This is to be used during the load routines.
         The reason for this is that sometimes you will not want to load
         every field that occurs in the input data files.  Specifying the
         special "NULL" value will allow you to skip over this field
         during the loading process to the next field.

         As an example we will assume that in input file in dBaseIII format
         contains four fields.  Field1 is the SSN, Field2 is the LastName,
         Field3 is the FirstName and Field4 is the MiddleInitial.  In order
         to load only the name fields you must be able to skip loading the
         SSN field.  To do this you would define the following array of
         LoadDef information :

           .
           .
           .

           FieldList : ARRAY [0 .. 3] OF DBLoad.LoadDef;
           .
           .
           .


           BEGIN
             FieldList[0].relation   := "NULL    ";
             FieldList[0].field      := "NULL    ";
             FieldList[0].repeat     := 1;
             FieldList[0].startIndex := 0;

             FieldList[1].relation   := "R1      ";
             FieldList[1].field      := "LastName";
             FieldList[1].repeat     := 1;
             FieldList[1].startIndex := 0;

             FieldList[2].relation   := "R1      ";
             FieldList[2].field      := "FirstNam";
             FieldList[2].repeat     := 1;
             FieldList[2].startIndex := 0;

             FieldList[3].relation   := "R1      ";
             FieldList[3].field      := "MiddleIn";
             FieldList[3].repeat     := 1;
             FieldList[3].startIndex := 0;
  *)

  TYPE
    LoadProc = PROCEDURE (VAR BOOLEAN);

    QuickProc = PROCEDURE (VAR ARRAY OF CHAR,
                           VAR BOOLEAN,
                           VAR BOOLEAN);

    (**
        LoadProc - Allows check of memory records and halting process.


        LoadProc allows the user to do any operations necessary on the
        data in the memory records after they have been loaded with data
        from the relations during an unload and with data from the
        file during the load routines.  During load routines this procedure
        should do a WriteRecord.  During the unload routines this procedure
        should do a ReadRecord.

      CALLING SEQUENCE -

        LoadProc (ContinueOn)

      EXIT -

        ContinueOn : BOOLEAN
          Set to FALSE if no further processing is desired.
          Set to TRUE if more data is to be read from the file.
    *)

    (**
        QuickProc - Allows user intervention during quick load.


        This procedure allows intervention prior to each record being loaded
        into the database.

        CALLING SEQUENCE -

          LoadProc (line, accept, continue)

        ENTRY -

          line : ARRAY OF CHAR
            The line that has just been read that is to be used to load field
            values from.  This line may be changed to include revised values
            if desired.

        EXIT -

          accept : BOOLEAN
            The load program should accept the line (TRUE), or reject and move
            to the next line without loading this line (FALSE).

          ContinueOn : BOOLEAN
            Set to FALSE if no further processing is desired.
            Set to TRUE if more data is to be read from the file.
    *)
    LoadDef = RECORD
      Relation   : ARRAY [0 .. 7] OF CHAR;    (* name of field's relation *)
      Field      : ARRAY [0 .. 7] OF CHAR;    (* name of field *)
      FldRepeat  : CARDINAL;                  (* field repeat number 1 .. n *)
      startIndex : CARDINAL;                  (* starts at position (1 .. n) *)
    END;




  PROCEDURE LoadDBaseIIIFormat
             (CONST FileName   : ARRAY OF CHAR;
              VAR   FieldTable : ARRAY OF LoadDef;
              CONST NumFields  : CARDINAL;
              CONST FormatProc : LoadProc);

  (**
      LoadDBaseIIIFormat - Load from a file which is in DBase III Format.


      LoadDBaseIIIFormat loads the data from a DBaseIII file into the relations
      and fields that were defined in the FieldTable.  The fields will be
      expected to be in the same order that they were defined.

      CALLING SEQUENCE -

        LoadDBaseIIIFormat (FileName, FieldTable, NumFields)

      ENTRY -

        FileName : ARRAY OF CHAR
          Name of the DBaseIII file to load from.

        FieldTable : ARRAY OF LoadDef
          Array of Relation-Field names to load.

        NumFields : CARDINAL
          Number of Relation-Field names in the FieldTable array.

      EXAMPLE -

        See bottom of .DEF file
  *)




  PROCEDURE LoadDelimitedFormat
             (CONST FileName       : ARRAY OF CHAR;
              VAR   FieldTable     : ARRAY OF LoadDef;
              CONST NumFields      : CARDINAL;
              CONST FieldDelimiter : CHAR;
              CONST AlphaDelimiter : CHAR;
              CONST HasHeaderRow   : BOOLEAN;
              CONST FormatProc     : LoadProc);

  (**
      LoadDelimitedForat - Load from a file which is in Delimited.


      LoadDelimitedFormat loads the data from a Delimited file into the relations and
      fields that were defined in the FieldTable.  The fields will be
      expected to be in the same order that they were defined.

      CALLING SEQUENCE -

        LoadDelimitedFormat (FileName, FieldTable, NumFields,
                             FieldDelimiter, AlphaDelimiter, FormatProc)

      ENTRY -

        FileName : ARRAY OF CHAR
          Name of the Delimited file to load from.

        FieldTable : ARRAY OF LoadDef
          Array of Relation-Field names to load.

        NumFields : CARDINAL
          Number of Relation-Field names in the FieldTable array.

        FieldDelimiter : CHAR
          The character to use between the field values

        AlphaDelimiter : CHAR
          The character to use around an alpha field value

        HasHeaderRow : BOOLEAN
          The first line of the data file is a header row of the field names.

        FormatProc : LoadProc
          Procedure to modify memory records, read and write records.

      EXAMPLE -

        See bottom of .DEF file
  *)




  PROCEDURE LoadDIFFormat
             (CONST FileName   : ARRAY OF CHAR;
              VAR   FieldTable : ARRAY OF LoadDef;
              CONST NumFields  : CARDINAL;
              CONST FormatProc : LoadProc);

  (**
      LoadDIFFormat - Load from a file which is in DIF format.


      LoadDIFFormat loads the data from a DIF file into the relations and
      fields that were defined in the FieldTable.  The fields will be
      expected to be in the same order that they were defined.

      CALLING SEQUENCE -

        LoadDIFFormat (FileName, FieldTable, NumFields, FormatProc)

      ENTRY -

        FileName : ARRAY OF CHAR
          Name of the DIF file to load from.

        FieldTable : ARRAY OF LoadDef
          Array of Relation-Field names to load.

        NumFields : CARDINAL
          Number of Relation-Field names in the FieldTable array.

        FormatProc : LoadProc
          Procedure to modify memory records, read and write records.

      EXAMPLE -

        See bottom of .DEF file
  *)




  PROCEDURE LoadSDFFormat
             (CONST FileName   : ARRAY OF CHAR;
              VAR   FieldTable : ARRAY OF LoadDef;
              CONST NumFields  : CARDINAL;
              CONST FormatProc : LoadProc);

  (**
      LoadSDFForat - Load from a file which is in Standard Data Format.


      LoadSDFFormat loads the data from a SDF file into the relations and
      fields that were defined in the FieldTable.  The fields will be
      expected to be in the same order that they were defined.

      CALLING SEQUENCE -

        LoadSDFFormat (FileName, FieldTable, NumFields, FormatProc)

      ENTRY -

        FileName : ARRAY OF CHAR
          Name of the SDF file to load from.

        FieldTable : ARRAY OF LoadDef
          Array of Relation-Field names to load.

        NumFields : CARDINAL
          Number of Relation-Field names in the FieldTable array.

        FormatProc : LoadProc
          Procedure to modify memory records, read and write records.

      EXAMPLE -

        See bottom of .DEF file
  *)




  PROCEDURE LoadSDIFormat
             (CONST FileName   : ARRAY OF CHAR;
              VAR   FieldTable : ARRAY OF LoadDef;
              CONST NumFields  : CARDINAL;
              CONST FormatProc : LoadProc);

  (**
      LoadSDIFormat - Load from a file which is in SDI format.


      LoadSDIFormat loads the data from a SDI file into the relations and
      fields that were defined in the FieldTable.  The fields will be
      expected to be in the same order that they were defined.

      CALLING SEQUENCE -

        LoadSDIFormat (FileName, FieldTable, NumFields)

      ENTRY -

        FileName : ARRAY OF CHAR
          Name of the SDI file to load from.

        FieldTable : ARRAY OF DBLoad.LoadDef
          Array of Relation-Field names to load.

        NumFields : CARDINAL
          Number of Relation-Field names in the FieldTable array.

      EXAMPLE -

        See bottom of .DEF file
  *)




  PROCEDURE UnloadDBaseIIIFormat
             (CONST FileName   : ARRAY OF CHAR;
              VAR   FieldTable : ARRAY OF LoadDef;
              CONST NumFields  : CARDINAL;
              CONST FormatProc : LoadProc);

  (**
      UnloadDBaseIIIFormat - Unload to a file which is in DBase III Format.


      UnloadDBaseIIIFormat unloads the data from the relations into a file
      in DBaseIII format using the relations and fields that were defined
      in the FieldTable.  The fields will be dumped in the same order that
      they were defined.

      CALLING SEQUENCE -

        UnloadDBaseIIIFormat (FileName, FieldTable, NumFields, FormatProc)

      ENTRY -

        FileName : ARRAY OF CHAR
          Name of the DBaseIII file to unload to.

        FieldTable : ARRAY OF LoadDef
          Array of Relation-Field names to load.

        NumFields : CARDINAL
          Number of Relation-Field names in the FieldTable array.

      EXAMPLE -

        See bottom of .ADS file
  *)




  PROCEDURE UnloadDelimitedFormat
             (CONST FileName         : ARRAY OF CHAR;
              VAR   FieldTable       : ARRAY OF LoadDef;
              CONST NumFields        : CARDINAL;
              CONST FieldDelimiter   : CHAR;
              CONST AlphaDelimiter   : CHAR;
              CONST IncludeHeaderRow : BOOLEAN;
              CONST FormatProc       : LoadProc);

  (**
      UnLoadDelimitedFormat - UnLoad to a file which is in Delimited format.


      UnLoadDelimitedFormat unloads the data from the database to a file
      which is in a Delimited format using the relations and fields
      that were defined in the FieldTable.  The fields will be unloaded
      in the same order as they were defined.

      CALLING SEQUENCE -

        UnLoadDelimitedFormat (FileName, FieldTable, NumFields,
                               FieldDelimiter, AlphaDelimiter, FormatProc)

      ENTRY -

        FileName : ARRAY OF CHAR
          Name of the DIF file to unload to.

        FieldTable : ARRAY OF LoadDef
          Array of Relation-Field names to unload.

        NumFields : CARDINAL
          Number of Relation-Field names in the FieldTable array.

        FieldDelimiter : CHAR
          The character to use between the field values

        AlphaDelimiter : CHAR
          The character to use around an alpha field value

        IncludeHeaderRow : BOOLEAN
          The first line of the data file will be a header row of the field names.

        FormatProc : LoadProc
          Procedure to modify memory records, read and write records.

      EXAMPLE -

        See bottom of .DEF file
  *)




  PROCEDURE UnloadDIFFormat
             (CONST FileName   : ARRAY OF CHAR;
              CONST Title      : ARRAY OF CHAR;
              VAR   FieldTable : ARRAY OF LoadDef;
              CONST NumFields  : CARDINAL;
              CONST FormatProc : LoadProc);

  (**
      UnLoadDIFFormat - UnLoad to a file in DIF format.


      UnLoadDIFFormat unloads the data from the database to a file
      which is in a DIF format using the relations and fields
      that were defined in the FieldTable.  The fields will be unloaded
      in the same order as they were defined.

      CALLING SEQUENCE -

        UnLoadDIFFormat (FileName, Title, FieldTable, NumFields, FormatProc)

      ENTRY -

        FileName : ARRAY OF CHAR
          Name of the DIF file to unload to.

        Title : ARRAY OF CHAR
          The title to be put in the DIF file.

        FieldTable : ARRAY OF LoadDef
          Array of Relation-Field names to unload.

        NumFields : CARDINAL
          Number of Relation-Field names in the FieldTable array.

        FormatProc : LoadProc
          Procedure to modify memory records, read and write records.

      EXAMPLE -

        See bottom of .DEF file
  *)




  PROCEDURE UnloadSDFFormat
             (CONST FileName   : ARRAY OF CHAR;
              VAR   FieldTable : ARRAY OF LoadDef;
              CONST NumFields  : CARDINAL;
              CONST FormatProc : LoadProc);

  (**
      UnLoadSDFFormat - UnLoad to a file which is in SDF format.


      UnLoadSDFFormat unloads the data from the database to a file
      which is in a SDF format using the relations and fields
      that were defined in the FieldTable.  The fields will be unloaded
      in the same order as they were defined.

      CALLING SEQUENCE -

        UnLoadSDFFormat (FileName, FieldTable, NumFields, FormatProc)

      ENTRY -

        FileName : ARRAY OF CHAR
          Name of the DIF file to unload to.

        FieldTable : ARRAY OF LoadDef
          Array of Relation-Field names to unload.

        NumFields : CARDINAL
          Number of Relation-Field names in the FieldTable array.

        FormatProc : LoadProc
          Procedure to modify memory records, read and write records.

      EXAMPLE -

        See bottom of .DEF file
  *)




  PROCEDURE UnloadSDIFormat
             (CONST FileName   : ARRAY OF CHAR;
              VAR   FieldTable : ARRAY OF LoadDef;
              CONST NumFields  : CARDINAL;
              CONST FormatProc : LoadProc);

  (**
      UnLoadSDIFormat - UnLoad to a file in SDI format.


      UnLoadSDIFormat unloads the data from the database to a file
      which is in a SDI format using the relations and fields
      that were defined in the FieldTable.  The fields will be unloaded
      in the same order as they were defined.

      CALLING SEQUENCE -

        UnLoadSDIFormat (FileName, FieldTable, NumFields)

      ENTRY -

        FileName : ARRAY OF CHAR
          Name of the SDI file to unload to.

        FieldTable : ARRAY OF CHAR
          Array of Relation-Field names to unload.

        NumFields : CARDINAL
          Number of Relation-Field names in the FieldTable array.

      EXAMPLE -

        See bottom of .DEF file
  *)




  PROCEDURE QuickLoadSDF
             (CONST FileName   : ARRAY OF CHAR;
              VAR   FieldTable : ARRAY OF LoadDef;
              CONST NumFields  : CARDINAL;
              CONST FormatProc : QuickProc);

  (**
      QuickLoadSDB - A highly optimized load from an SDF format file.


      This procedure performs a highly optimized load using various Sage
      procedures such as ProcessAdd.  An index must be rebuilt afterwards
      by the calling program using Sage.RebuildIndex.  The 'FormatProc'
      for this procedure is different than the standard load format, giving
      a view of the line to be loaded and allowing modification or rejection
      of that line as well as the standard discontinuance of the process.

      It is assumed that all of the relations that are involved in this
      process are already open when this procedure is called.

      CALLING SEQUENCE -

        QuickLoadSDF (FileName, FieldTable, NumFields, FormatProc)

      ENTRY -

        FileName : ARRAY OF CHAR
          Name of the SDF file to load from.

        FieldTable : ARRAY OF LoadDef
          Array of Relation-Field names to load.

        NumFields : CARDINAL
          Number of Relation-Field names in the FieldTable array.

        FormatProc : QuickProc
          Procedure that allows the modification or rejection of the input
          line, or discontinuance of the process.
  *)




  PROCEDURE UnloadDumpFormat
             (CONST DataDumpFile  : ARRAY OF CHAR;
              CONST BlockDumpFile : ARRAY OF CHAR;
              CONST Path          : ARRAY OF CHAR;
              CONST Relation      : ARRAY OF CHAR;
              CONST KeyField      : ARRAY OF CHAR);

  (**
      UnloadDumpFormat - Dump data to two files in an internal ASCII format.


      This procedure dumps the data to ascii files.  The block data fields
      are dumped to a seperate file.

      CALLING SEQUENCE -

        UnloadDumpFormat (DataDumpFile, BlockDumpFile, Path,
                          Relation, KeyField);

      ENTRY -

        DataDumpFile : ARRAY OF CHAR
          Name of the file to get the relation field data.

        BlockDumpFile : ARRAY OF CHAR
          Name of the file to get the block data.

        Path : ARRAY OF CHAR
          Path to the files being dumped.

        Relation : ARRAY OF CHAR
          Name of the relation to read through.

        KeyField : ARRAY OF CHAR
          Name of the key field to use when dumping.

  *)




  PROCEDURE LoadDumpFormat
             (CONST DataDumpFile  : ARRAY OF CHAR;
              CONST BlockDumpFile : ARRAY OF CHAR;
              CONST Path          : ARRAY OF CHAR;
              CONST Relation      : ARRAY OF CHAR;
              CONST KeyField      : ARRAY OF CHAR);

  (**
      LoadDumpFormat - Load data from two files in an internal ASCII format.


      This procedure loads the data from ascii files.  The block data fields
      were dumped to a seperate file.

      CALLING SEQUENCE -

        LoadDumpFormat (DataDumpFile, BlockDumpFile, Path,
                        Relation, KeyField);

      ENTRY -

        DataDumpFile : ARRAY OF CHAR
          Name of the file containing the relation field data.

        BlockDumpFile : ARRAY OF CHAR
          Name of the file containing the block data.

        Path : ARRAY OF CHAR
          Path to the files being loaded.

        Relation : ARRAY OF CHAR
          Name of the relation to add data to.

        KeyField : ARRAY OF CHAR
          Name of the key field to use loading.

  *)




Send mail to   warren.merrill@inl.gov with questions or comments about this web site.
Copyright © 1989-2006 Battelle Energy Alliance