Delete midrange of records with DBU - Clipper

This is a discussion on Delete midrange of records with DBU - Clipper ; Is there a way to delete a range of corrupt records in the middle of a dbf file with DBU or a similar utility? A chunk of these records in the same DBF are duplicated - any ideas of how ...

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Delete midrange of records with DBU

  1. Default Delete midrange of records with DBU

    Is there a way to delete a range of corrupt records in the middle of a dbf
    file with DBU or a similar utility?

    A chunk of these records in the same DBF are duplicated - any ideas of how
    this corruption could occur?

    Thanks,

    Donald Leask
    Johannesburg.



  2. Default Re: Delete midrange of records with DBU

    Donald,

    >Is there a way to delete a range of corrupt records in the middle of a dbf
    >file with DBU or a similar utility?


    Make a copy of the dbf to experiment with. If the records are
    corrupted in the sense that there are garbage characters that Clipper
    chokes on when the record is read into variables, then I would try to
    find out which records are affected and write a little program that
    deletes them based on the record number. Then copy to a new dbf for
    !deleted().

    >A chunk of these records in the same DBF are duplicated - any ideas of how
    >this corruption could occur?


    This sounds like either a PACK attempt that crashed in the middle of
    the operation (IMO this is the prime suspect and the exact reason why
    PACK should never, never ever be used) or a hardware related problem.
    I have seen examples of the latter kind where whatever happened to be
    in a cache was written to disk on top of an existing dbf.

    Regards,
    Klas

    -------
    klas dot engwall at engwall dot com

    http://www.engwall.com/clipper/

    The LFN Library for Clipper
    The LanMan Library for Clipper
    The NFPAT1A Timeslice release patch for the Nanforum Toolkit

  3. Default Re: Delete midrange of records with DBU

    Thanks Klas

    What would the core of this program look like? Forcing physical deletion?
    Pack?!!!

    Donald.



  4. Default Re: Delete midrange of records with DBU

    Donald

    // This presumes you know which records are corrupt
    // you'll need a tool like BRO (maybe DBU will do) to get the record numbers
    // ie you'll have to do something by hand as there is no automatic way of
    identifying corrupt records

    aArray := { 1, 2, 33, 55, 78, 99 }
    for i := 1 to len( aArray )
    x->( DBGoto( aArray[1] )
    x->( DBDelete() )
    next
    PACK

    What I used to do was
    COPY TO xyz
    and after it failed checked the last record written to the xyz.dbf.
    Load up the crook dbf in BRO and delete that record and any I thought was
    corrupt around that record (+50-100)
    Repeat the COPY TO until it completed successfully.

    You'll find it easier to delete any indexes involved as well.

    HTH
    Steve



  5. Default Re: Delete midrange of records with DBU

    Donald,

    >What would the core of this program look like? Forcing physical deletion?


    That depends on the type of corruption, and you haven't said much
    about that yet. If it is just the duplicate records you mentioned
    yesterday, then all you have to do is identify them and delete() them
    plus copy to a new file for !deleted() as the final step.

    If there is garbage in the records you will have to try different
    solutions until you find one that works. The ones Steve mentioned, for
    example, and if nothing else helps maybe calculating the offsets of
    the corrupted records in the file and fwrite()ing space characters as
    replacement for the garbage. It is diffifult to say how much brute
    force you will have to use without really knowing what the problem is.

    But in any case, first you have to identify the record numbers of the
    corrupted records. And as I said yesterday, make a copy of the file
    before you do anything at all!!

    >Pack?!!!


    You're kidding, right? :-)

    Regards,
    Klas

    -------
    klas dot engwall at engwall dot com

    http://www.engwall.com/clipper/

    The LFN Library for Clipper
    The LanMan Library for Clipper
    The NFPAT1A Timeslice release patch for the Nanforum Toolkit

  6. Default Re: Delete midrange of records with DBU

    Steve,

    >aArray := { 1, 2, 33, 55, 78, 99 }
    >for i := 1 to len( aArray )
    > x->( DBGoto( aArray[1] )


    perhaps x->( DBGoto( aArray[i] ) would be more efficient :-)

    > x->( DBDelete() )
    >next
    >PACK


    Oh no, Steve, you said the "P" word right after I tried to push Donald
    away from that and show him copy for !deleted() instead :-)

    The duplicate records he said that he has in the middle of the file
    sounds suspiciously like there has been a PACK crash already.

    Regards,
    Klas

    -------
    klas dot engwall at engwall dot com

    http://www.engwall.com/clipper/

    The LFN Library for Clipper
    The LanMan Library for Clipper
    The NFPAT1A Timeslice release patch for the Nanforum Toolkit

  7. Default Re: Delete midrange of records with DBU

    Klas

    > Oh no, Steve, you said the "P" word right after I tried to push Donald
    > away from that and show him copy for !deleted() instead :-)

    I've never had a problem using pack on my machine for maintenance purposes <g>
    - never used it in an app though IIRC as I used to recycle deleted records

    > The duplicate records he said that he has in the middle of the file
    > sounds suspiciously like there has been a PACK crash already.

    That may have been an OS/Machine/Disk space/Network problem while 'packing'
    though.

    CYA
    Steve



  8. Default Re: Delete midrange of records with DBU

    "Donald Leask" <vet@svh.co.za> wrote in message
    news:e9o278$k2i$1@ctb-nnrp2.saix.net...
    > Is there a way to delete a range of corrupt records in the middle of a dbf
    > file with DBU or a similar utility?
    >
    > A chunk of these records in the same DBF are duplicated - any ideas of how
    > this corruption could occur?
    >
    > Thanks,
    >
    > Donald Leask
    > Johannesburg.
    >
    >


    to clean dbf with dbu i use:

    a] with dbu detect first/last recno of corrupted area
    b] then, copy to temporary file [without any index], with clause

    recno()<first_corrupted .or. recno()>last_corrupted

    if you have few corrupted areas, repeat steps a] and b], you have to copy in
    chain, always using previously copied temp file.

    at the end, backup orig dbf, and replace it with last temp file, and
    recreate indices






  9. Default Re: Delete midrange of records with DBU

    Steve,

    >> Oh no, Steve, you said the "P" word right after I tried to push Donald
    >> away from that and show him copy for !deleted() instead :-)

    >I've never had a problem using pack on my machine for maintenance purposes <g>
    > - never used it in an app though IIRC as I used to recycle deleted records
    >
    >> The duplicate records he said that he has in the middle of the file
    >> sounds suspiciously like there has been a PACK crash already.

    >That may have been an OS/Machine/Disk space/Network problem while 'packing'
    >though.


    Or ...
    .... user's knee hitting the reset button under the table
    .... user's foot getting entangled in the power cord
    .... user's co-worker blowing the fuse
    .... user turning off the computer to go home
    .... non-thinking admin rebooting the server

    The list goes on and on <g>

    Regards,
    Klas

    -------
    klas dot engwall at engwall dot com

    http://www.engwall.com/clipper/

    The LFN Library for Clipper
    The LanMan Library for Clipper
    The NFPAT1A Timeslice release patch for the Nanforum Toolkit

  10. Default Re: Delete midrange of records with DBU

    This works just fine - thanks!

    BTW what would a DO WHILE loop to delete a range of records look like....
    with variables nRangeStart and nRangeEnd?

    Thanks,
    Donald.

    "sali" <sali@tel.net.ba> wrote in message
    news:e9u5o0$b5j$1@ls5.tel.net.ba...
    > "Donald Leask" <vet@svh.co.za> wrote in message
    > news:e9o278$k2i$1@ctb-nnrp2.saix.net...
    >> Is there a way to delete a range of corrupt records in the middle of a
    >> dbf
    >> file with DBU or a similar utility?
    >>
    >> A chunk of these records in the same DBF are duplicated - any ideas of
    >> how
    >> this corruption could occur?
    >>
    >> Thanks,
    >>
    >> Donald Leask
    >> Johannesburg.
    >>
    >>

    >
    > to clean dbf with dbu i use:
    >
    > a] with dbu detect first/last recno of corrupted area
    > b] then, copy to temporary file [without any index], with clause
    >
    > recno()<first_corrupted .or. recno()>last_corrupted
    >
    > if you have few corrupted areas, repeat steps a] and b], you have to copy
    > in
    > chain, always using previously copied temp file.
    >
    > at the end, backup orig dbf, and replace it with last temp file, and
    > recreate indices
    >
    >
    >
    >
    >




+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. Automatically Delete Records from a Table
    By Application Development in forum ADO DAO RDO RDS
    Replies: 2
    Last Post: 11-01-2007, 07:11 PM
  2. delete records from database
    By Application Development in forum Inetserver
    Replies: 8
    Last Post: 05-16-2006, 10:14 PM
  3. ASP delete records problem
    By Application Development in forum Inetserver
    Replies: 2
    Last Post: 02-28-2006, 09:50 AM
  4. delete related records
    By Application Development in forum Inetserver
    Replies: 3
    Last Post: 11-21-2005, 07:53 PM
  5. need a utility to delete records ( dos )
    By Application Development in forum Clarion
    Replies: 0
    Last Post: 09-21-2005, 10:14 PM