Re: REWRITE query

From: William M. Klein (wmklein_at_nospam.netcom.com)
Date: 01/20/04


Date: Tue, 20 Jan 2004 22:17:15 GMT

Your problem is:

 move account-no-in to file1-key
read file1
invalid key

for a file in DYNAMIC access mode, a "read" with no KEY phrase is a SEQUENTIAL
read, so you are actually just doing a "read next". You can either use the
START statement to position your read or use the KEY phare on the READ.

-- 
Bill Klein
 wmklein <at> ix.netcom.com
"ritchie" <ritchie_s01@yahoo.com> wrote in message
news:3bee6ba6.0401201007.4dd29014@posting.google.com...
> Hi,
>
> I am trying to amend a record already on file using rewrite.
> This para first gets the account number to be amended, from the user.
> Then reads 'file1' to see if this account exists.  Then, if it does,
> it reads 'file2'
> for the first transaction corresponding to this account number, and
> displays the amount.
> I then try to do a rewrite of the amount but get a file status 23 even
> though this
> record is on file2.
>
> This file status of '23' (record not found) is after the rewrite.
> When I read the file before-hand it displays the correct amount for
> that specific
> account, as it should, but then I try to rewrite with the new amount
> and have this problem.
> I have checked the file keys and they 'seem' to have the correct
> values.
>
> This is the same file setup I use for adding to both 'file1' and
> 'file2' and I have no
> problems there.
>
> I'm not sure what's going wrong here.
> Could the keys be defined incorrectly?  I suspect that this could be
> the case.
>
> Any help would be much aprechiated.
>
> Thanks in advance,
> Ritchie
>
> P.S (using Fujitsu v3 compiler)
> PLEASE forgive the formatting.
>
> ************* START CODE
> **********************************************
> FILE-CONTROL.
> select file1 assign "file1.dat"
> ORGANIZATION IS Indexed
>         ACCESS MODE IS DYNAMIC
> RECORD KEY IS Account-no
> ALTERNATE RECORD KEY IS Account-name
> WITH DUPLICATES
> FILE STATUS IS file1-status.
> select Transactions ASSIGN TO "file2.dat"
> ORGANIZATION IS Indexed
> ACCESS MODE IS DYNAMIC
> RECORD KEY IS Transaction-no
> ALTERNATE RECORD KEY IS Transaction-date
> WITH DUPLICATES
> FILE STATUS IS file2-status.
> ...
> FD Accounts.
> 01 file1.
> 03 Account-no PIC X(14).
> 03 Account-lname PIC A(30).
> ....
> FD Transactions.
> 01 file2.
> 03 Transaction-no.
> 05 Transaction-ac PIC X(14).
> ...
> 05 trans-amt PIC 9(5)v99.
> ...
> AMEND-TRANS
> ***get account num from user
> display "Enter account no > "
> accept account-no-in
> ***move value to file1 key
> move account-no-in to file1-key
> read file1
> invalid key
> ..
> not invalid key
> if file-status-ok
> display "Account found"
>           end-if
> ***move file1 key to file2 key for read of file2
> move file1-key to file2-key
>
> set not-eof-file2 to true
> ***start file2 at position of the account number found from file1 read
> (ok up to here)
> start file2 KEY >= account-no-in
>
> perform until eof-file2 or file1-key not = Transaction-ac
> read file2 next record at end set eof-file2 to true
> not at end
> if file1-key = file2-key
> set not-eof-file2 to true
> ***display amount fr this account (still ok up to here)
> display "Transaction old amount > " trans-amt
>
>                         display "Enter new amount"
> accept new-amt
>
> move new-amt TO trans-amt
> rewrite file2
> end-rewrite
> ***ERROR - file status 23 here - but record is on file.
> end-if
> end-read
> end-perform.
> ***********************END CODE***************************************


Relevant Pages

  • Re: Text Script
    ... What is the template for the item you are searching for? ... I have file1 that comes from one ... I have File2 from another computer that is in no order either. ... > need to readline in file2 to find an account number. ...
    (microsoft.public.windows.server.scripting)
  • Re: Text Script
    ... I have file1 that comes from one ... I have File2 from another computer that is in no order either. ... need to readline in file2 to find an account number. ... > records to a third file on the same line, or to cause the original similar ...
    (microsoft.public.windows.server.scripting)
  • Re: Text Script
    ... I have file1 that comes from one ... >>> computer with dollar figures in it listed by account number in no ... I have File2 from another computer that is in no order either. ... >>> I know I need to use one file as my master to query the second file ...
    (microsoft.public.windows.server.scripting)
  • Re: Text Script
    ... Basically this is an account number that is 12 digits long found in different ... I have file1 that comes from one ... >>> and of the problem set. ... >>> records to a third file on the same line, ...
    (microsoft.public.windows.server.scripting)
  • Re: Newbie question about db normalization theory: redundant keys OK?
    ... fan of persistent message queues. ... If your queue is ... Or if some of the queued transactions can be rolled ... geographically separated databases storing account balances. ...
    (comp.databases.theory)