TAA Tools
TAADBFW         RETRIEVE DELETED RECORDS               TAADBFW

The Retrieve  Deleted Records command  allows the retrieval  of deleted
records  from a  physical file.   Some  restrictions  exist such  as no
variable  length  records,  null fields,  or  REUSEDLT(*YES).   Deleted
records cannot be retrieved if RGZPFM occurs or CLRPFM.

A typical command would be:

        RTVDLTRCD   FROMFILE(xxx) TOFILELIB(yyy)

This would extract the deleted  records in the FROMFILE and  write them
to the same named file in the library specified for TOFILELIB.

When a  record is deleted  in a data  base file, the data  values still
exist,  but  the system  places a  special hex  value  in front  of the
record specifying that  it is deleted.   The Operating System  prevents
any access to a deleted record thru its normal interfaces.

When  the file  is  saved, all  the information  from  both active  and
deleted  records are saved.   The RTVDLTRCD command saves  the file you
specified to a  save file  and then  searches for  the deleted  records
and writes them to the same file name in a different library.

When a file  is cleared, the end of  file indicator is set back  to the
beginning  of  the  file  and  the  records cannot  be  retrieved  with
RTVDLTRCD.    When a  file  is reorganized,  the  data is  copied  to a
temporary  file  without  the  deleted  records.    Therefore,  deleted
records cannot be retrieved after RGZPFM.

There are a few things to consider:

  **   RTVDLTRCD can  only be  used by  the owner of  the file,  if the
       owner  is the group profile of the  current user, or a user with
       *ALLOBJ authority.

  **   A file of  the same  name as  the file you  are retrieving  from
       must  not  exist  in  the  TOFILELIB.     A  new  file  will  be
       automatically created using the format of the FROMFILE.

  **   An option  exists to allow a relative  record number field to be
       added to the new  file.  This will  contain the relative  record
       number of where the record was found in the FROMFILE.

  **   Files  with  variable  length fields  or  null  fields  are  not
       supported.

  **   No  date information is  kept by the  system on when  the record
       was deleted.

  **   Files  with Date  (L), Time  (T), or  Timestamp (Z)  type fields
       are supported.   Although the  system keeps  the data for  these
       fields  in  a  different  format   that  is  seen  in  the  data
       management  buffer, RTVDLTRCD simulates what  the system does to
       map the data  into a  record buffer before  writing the  record.
       There  is  a restriction  where  these  types of  fields  cannot
       exist  in  the  first  5  positions  of  the  record.   See  the
       following discussions.

If the records  retrieved contain only  blanks or zeros,  see the  next
two sections.

How RTVDLTRCD operates internally
---------------------------------

The file is checked  to ensure it contains deleted records  and if none
exist, an error message occurs.

The file  definition is checked  to determine if any  field types (such
as  variable  length)  exist  and  if  so,  RTVDLTRCD  sends  an  error
message.

If Date, Time, or  Timestamp fields exist, the actual record  length of
the  record  when Saved  is  calculated (this  will  be  less than  the
external record length as seen by DSPFD).

A  duplicate file definition  is created in  QTEMP and  a single record
is initialized  in  this file.    The record  is  then updated  so  the
characters *TAA* exist in positions 1 - 5.

The  real  file data  is  then  copied  (added  to) to  this  duplicate
version.   A save  file is  created in QTEMP  and the QTEMP  version of
the file is saved.

The save file data is then read  by a program that scans for the  first
record (the *TAA* record).   Once it is found, the  program knows where
to start in the save file data to check for records.

Each  record is preceded  by a single  byte that determines  whether it
is  a 'live' or 'deleted'  record.  When a  deleted record is found, it
is written to  the file in the  TOFILELIB parameter.  Special  handling
must occur  if any Date,  Time, or Timestamp  fields exist as  the data
must  be  reformatted  to appear  in  the buffer  as  expected  by data
management.

Determining if deleted records contain blanks or zeros
------------------------------------------------------

In some  cases  RTVDLTRCD may  produce a  new  file that  contains  all
blanks and zeros for  data.  This may be due to  an application program
which initializes the format of the record before deleting it.

You  can determine if the  deleted records actually  contain blanks and
zeros by  using the  CHKDLTRCD  command (part  of the  RTVDLTRCD  tool)
with the exception of files defined with:

        - Null values
        - Variable length fields
        - Reuse deleted records

Do the following:

  **   Use  PRTDLTRCD for  the file  and  member.   This  will print  a
       listing of where  the deleted records are.   Try to find a range
       where   several  deleted  records   exist  consecutively.    For
       example, if  the listing  shows  a 'Start  RR Nbr'  of 1000  and
       'Ending  RR Nbr'  of  1099, there  are  100 consecutive  deleted
       records  beginning at relative record number  1000.  If you have
       a reasonable range  of consecutive  deleted records, you  should
       have  the  information  you  need to  make  a  determination  if
       blanks and zeros exist.

  **   Determine the  relative record number of  the first record prior
       to a group of  consecutive deleted records.   In the example  of
       100  consecutive deleted  records  beginning at  1000,  relative
       record number 999 is the first active prior record.

  **   Determine a  unique value in  this active record.   Knowing what
       the   first  active  data  record   looks  like  will  help  you
       determine where  the deleted records  begin when  displayed.   A
       good tool to use is DSPDB:

             DSPDB    FILE(xxx) FROMRCD(nnn)

       Identify a unique  value in the record such as  few bytes from a
       name  field.  You need  to know the  approximate position in the
       record where the  unique value  exists and how  long the  record
       is.

  **   Enter the  following command using  the FROMRCD as  the relative
       record  number   of  the  first  active   record  prior  to  the
       consecutive group of deleted records  and the TORCD as the  last
       relative record number in the group.

             CHKDLTRCD     FILE(xxx) MBR(yyy) FROMRCD(nnn) TORCD(nnn)

       This will  create the TEMPFILE  in QTEMP,  by copying the  range
       of  relative  record  numbers   you  specified.    A  save  file
       (TEMPSAVF)  is then created in QTEMP,  and the created data base
       file is  saved.   The save  file is  then copied  to the  RCD528
       file in QTEMP and the file will be displayed using DSPPFM.

       Each record in  a save file is  528 bytes long.  The  last 12 or
       so  bytes contain  control information in  each record.   A data
       record may be  completely contained in the  save file record  or
       it may span  a record.  There  is a byte that  precedes the data
       for  each  record that  determines  if the  record  is  valid or
       deleted.  In some cases, a  record will span the 528 byte  area.

  **   Instructions will  appear about  how to  use the DSPPFM  display
       to  determine the  data in your  deleted records.   You  need to
       scan  for  the  unique value  in  the first  active  record (the
       beginning  of  the  file   has  a  good  deal  of   Save/Restore
       information that you want to bypass).

       Use  F10 to  display the  data in  hexadecimal.   Then determine
       whether  the following deleted records  contain blanks or zeros.

              Date and Time Fields
              --------------------

If your file  contains date and  time fields, the  length which  exists
on disk  and the  buffer length as  seen by a  program differ.   DSPPFM
will  display  the  value  as  kept  on  disk  which is  compressed  as
follows:

          Type of field       Disk length     Buffer length
          -------------       -----------     -------------

            L = Date                4              10
            T = Time                3               8
            Z = Timestamp          10              26

When the data  appears for date/time  values, you will not  be able  to
determine  the  actual  value because  of  the  compression  technique.
Look for data in fields other than date and time fields.


Operating on a locked file
--------------------------

Because  a SAVOBJ  must  occur to  access the  records,  RTVDLTRCD will
fail if the file is open for update.

CPYF  should be  considered in  this case  to copy  the file to  a work
file  and   retain   the  deleted   records.     Use   FROMRCD(1)   and
COMPRESS(*NO) when copying.

Working with the deleted records
--------------------------------

In some  situations, you may want  to recover only some  of the deleted
records that have been retrieved.  You could do the following:

  **   Specify  RELRCD(*YES)  on  the  RTVDLTRCD  command.   This  will
       provide  you  with   a  simple  unique   key  for  each   record
       retrieved.

  **   Get a  printed listing  of the deleted  records and  include the
       relative record number.  You could use the TAA tool DSPDBF.

  **   Determine what deleted records you want to recover.

  **   If  you only  want a  few, you  could use  CPYF with  the INCREL
       parameter and specify  the field  name for  the relative  record
       number.  For  example, assume you retrieved the  deleted records
       from FILEA in  LIB1 and wrote the records to  LIB2.  A new FILEA
       is   automatically  created  in  LIB2   with  just  the  deleted
       records.   It uses  the same format  plus a  field for  relative
       record  number.    Assume  you  created  FILEA2  in  LIB2  as  a
       duplicate  of FILEA in  LIB2 and  want to copy  record number 26
       (this was the record  at relative record  number 26 in FILEA  in
       LIB1).

            CPYF    FROMFILE(LIB2/FILEA)
                      TOFILE(LIB2/FILEA2)
                      MBROPT(*ADD)
                      INCREL((*IF TAAREL *EQ 26))

  **   If you want  to use most of  the deleted records, you  could use
       DFU to delete those that you did not want.

  **   When  you have a  net file of  the records you  want to recover,
       you can use CPYF to copy back  to the original file.  Note  that
       the records  will not  be written  back to  the original  record
       numbers.   If you need  to reuse the exact  same relative record
       numbers,  you could  write a  program to  do so using  the TAARR
       field.

RTVDLTRCD Command parameters                          *CMD
----------------------------

   FROMFILE      The qualified file  name of the  file to retrieve  the
                 deleted records  from.  The library  value defaults to
                 *LIBL.

   TOFILELIB     The  library where  a duplicate  file will  be created
                 to hold  the  deleted records.    The same  file  name
                 will  be  used.    The file  must  not  exist  in  the
                 TOFILELIB.   The format  of the original  file is used
                 (Also see the  RELRCD parameter).   The new file  will
                 be created in arrival sequence (no key fields).

   FROMMBR       The member of  the FROMFILE to  be used.   The default
                 is *FIRST.

   RELRCD        A  *YES/*NO   value  that  defaults  to   *NO.    *YES
                 specifies  that  you  want  a  relative  record number
                 field to  be added  to each  record in  the new  file.
                 The  field (TAARR)  will contain  the relative  record
                 number  of where the record was  in the FROMFILE.  The
                 relative record  number  field will  be added  at  the
                 end of all  other fields in the format  and is defined
                 as packed with 13 digits and 0 decimals.

CHKDLTRCD Command parameters                          *CMD
----------------------------

   FROMFILE      The  qualified  file name  of  the file  to  check for
                 deleted records.   The library  qualifier defaults  to
                 *LIBL.  *CURLIB may also be used.

   FROMRCD       The 'from relative  record' number to check.   See the
                 tool   documentation   section   on  'Determining   if
                 deleted records contain blanks or zeros'.

   TORCD         The  'to relative  record' number  to check.   See the
                 tool   documentation  section   on   'Determining   if
                 deleted records contain blanks or zeros'.

   MBR           The  member  name  to  be  checked.   The  default  is
                 *FIRST  for the first  member of the file.   *LAST may
                 be specified to check the last member in the file.

   ALWACTIVE     Whether to  allow  active  records  in  the  range  of
                 FROMRCD/TORCD.

                 *YES is the  default to assume that  you are beginning
                 the  copy  with the  first  active record  prior  to a
                 group of consecutive deleted records.

                 *NO may be  specified if the  range of records  should
                 include only deleted records.

Restrictions
------------

  **   The RTVDLTRCD  command  can only  be used  by the  owner of  the
       file or a user with *ALLOBJ authority.

  **   The deleted  records must still  exist in the file.   This means
       that you have not done a CLRPFM, RGZPFM etc.

  **   If  the  file  is  specified  as  REUSEDLT(*YES)  you  may  have
       already added  a  new record  on  top of  a deleted  record  you
       would like to recover.

  **   Only a  physical data  file can be  specified.  Source  files or
       logical  files may not be used (The  typical use of source files
       is with SEU  which uses  a work  space so that  all records  are
       written  back  when  SEU  ends so  that  there  are  no  deleted
       records).

  **   Files  with  variable  length  fields  or  null fields  are  not
       supported.

  **   Graphic type fields are not supported.

  **   A minimum record size of 5 bytes is supported.

  **   A maximum record size of 4000 bytes is supported.

  **   The maximum number of fields in the file cannot exceed 998.

Prerequisites
-------------

To help control  the use  of the  command, it  must be  created by  the
Security Officer  or a  member of his  group.   The command  is created
with the public excluded.

The following TAA Tools must be on your system:

     CHKOBJ3      Check object 3
     CPYFRMSAVF   Copy from save file
     CVTDAT2      Convert date 2
     EDTVAR       Edit variable
     DUPFILFMT    Duplicate file format
     HLRMVMSG     HLL Remove message
     PAUSE        Pause
     RSNLSTMSG    Resend last message
     RTVDBFA      Retrieve data base file attributes
     RTVFLDARR    Retrieve field array
     RTVPFSRC     Retrieve PF source
     SNDCOMPMSG   Send completion message
     SNDDIAGMSG   Send diagnostic message
     SNDESCMSG    Send escape message
     SNDSTSMSG    Send status message
     WRTSRC       Write source

Implementation
--------------

None, the tool is ready to use.

Objects used by the tool
------------------------

   Object        Type        Attribute      Src member    Src file
   ------        ----        ---------      ----------    ----------

   RTVDLTRCD     *CMD                       TAADBFW       QATTCMD
   CHKDLTRCD     *CMD                       TAADBFW4      QATTCMD
   TAADBFWC      *PGM           CLP         TAADBFWC      QATTCL
   TAADBFWC2     *PGM           CLP         TAADBFWC2     QATTCL
   TAADBFWC3     *PGM           CLP         TAADBFWC3     QATTCL
   TAADBFWC4     *PGM           CLP         TAADBFWC4     QATTCL
   TAADBFWR      *PGM           RPG         TAADBFWR      QATTRPG
   TAADBFWR2     *PGM           RPG         TAADBFWR2     QATTRPG
   TAADBFWR3     *PGM           RPG         TAADBFWR3     QATTRPG
   TAADBFWR5     *PGM           RPG         TAADBFWR5     QATTRPG
   TAADBFWR9     *PGM           RPG         TAADBFWR9     QATTRPG

Structure
---------

RTVDLTRCD       Cmd
  TAADBFWC        CL Pgm
     TAADBFWR2      RPG pgm to check for var len fields etc
     TAADBFWC2      CL Pgm  Checks authority
     TAADBFWR       RPG Pgm  Reads save file data
        TAADBFWC2      CL Pgm   Checks authority
        TAADBFWR5      RPG Pgm  Handles reformatting of Date/Time etc
          TAADBFWR9      RPG Pgm  Determines yyyymmdd for disk format
          TAADBFWC3      CL Pgm   Does CVTDAT2 from yyyymmdd

CHKDLTRCD       Cmd
  TAADBFWC4       CL Pgm
					

Added to TAA Productivity tools April 1, 1995


Home Page Up to Top