Error when deleting the last record out of a file

Brian K. White brian at aljex.com
Thu Dec 13 16:18:29 PST 2007


----- Original Message ----- 
From: "Mike Schwartz" <mschw at athenet.net>
To: <filepro-list at lists.celestial.com>
Sent: Thursday, December 13, 2007 6:13 PM
Subject: Error when deleting the last record out of a file


>     One of my customers (filePro 5.0.5K2R4, SCO Unix 5.0.6) has a general
> purpose temporary storage file that can be used to hold records temporarily
> when running various reports.  The first field is the TTY number, the second
> field is a 2 letter application ID, AP=accounts payable, etcetera, and the
> 3rd is a 2-letter report ID ("32" is the number I was assigned for this
> project).  After that there are ten 60-character "general purpose" alpha
> data fields.  There is only one automatic index (old pre-4.5 index) that
> spans the first 5 fields (length 132).  
> 
>    This file is used simultaneously by multiple applications and multiple
> users concurrently.  I can't simply blow away the entire key file (ddir
> -KA), because other users may be storing new records in the file at the same
> time I'm trying to remove my old records.  
> 
>    The system works fine, except when finish my processing, I need to
> delete out all the records I have put there, and when I am deleting the very
> last record out of the file, I get the error:
> 
> /u/filepro/storesort/indexabc.A: invalid argument
> 
> Dummy field tt contains the users tty#.
> 
> ClrSrt   If: 'Clear out the storesort file after we're done...
>       Then: '(Also:  Clear HD32's before we start...)
> 220  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>         If:
>       Then: lookup stx = storesort  K=("TTY")  i=A -bpG
> 221  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
> NXTstx   If: not stx                'No more recs to delete for HD32
>       Then: sleep "1000";  return
> 222  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>         If: stx(2)="HD" and stx(3)="32"
>       Then: show ("10","1")  "Deleting" <stx(4)
> 223  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>         If: stx(2)="HD" and stx(3)="32"
>       Then: delete stx
> 224  -------   -   -   -   -   -   -
>         If:
>       Then: getnext stx; goto NXTstx
> 
>     I run this at the beginning of my processing and also at the end.  Note
> the "greater than" at the end of the lookup.   Should I try a different
> lookup key?  (There should never be any records in the file that starts with
> anything other than TTY.)  During the overnight processing, this entire file
> does get "blown away" with a ddir -KA command, so it starts clean each day.
> 
>     The show statement makes it appear that I'm reading through all 3,000
> records I'm storing and then blowing up on the last record, or immediately
> after the last record is deleted.  I'm probably getting an error on the
> "getnext" as it reads off the end of the file or some such thing.    
> 
> Any suggestions?
> 
> Thanks!
> 
> Mike Schwartz

Isn't there more to the error, like a line number?

I think the lookup needs to be -npx not -bpg considering the surrounding code.
I think the way it is now, you are quickly reading the matching records, then reading every remaining record from the last match to the end of the file. (by index A sort, not record number)

With -npx, you will get a "not stx" gracefully, as soon as the last matching record has been read.
I don't think you need to change anything else, just change "-bpG" to "-npx" and try that.

Brian K. White    brian at aljex.com    http://www.myspace.com/KEYofR
+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
filePro  BBx    Linux  SCO  FreeBSD    #callahans  Satriani  Filk!




More information about the Filepro-list mailing list