REWRITE query

From: ritchie (ritchie_s01_at_yahoo.com)
Date: 01/20/04

  • Next message: Habitant: "Red faces about Mars?"
    Date: 20 Jan 2004 10:07:03 -0800
    
    

    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***************************************


  • Next message: Habitant: "Red faces about Mars?"

    Relevant Pages

    • Re: Scott Adams: Absolute loon (new revelations from "Gods Debris")
      ... Cheezits wrote: ... >>>guy who thought we had to rewrite all of modern science to account ...
      (talk.origins)
    • Re: REWRITE query
      ... > I am trying to amend a record already on file using rewrite. ... > This para first gets the account number to be amended, ... > ALTERNATE RECORD KEY IS Account-name ... > RECORD KEY IS Transaction-no ...
      (comp.lang.cobol)
    • Re: 3e Classic Old Style modules?
      ... have known to take some aspects of RL geology into account. ... the rewrite has no need of it. ... return to G-series form, but since superceded stylistically by Carl ...
      (rec.games.frp.dnd)
    • Re: OPTIMIZER LOCK HINTS
      ... I rewrite to: ... INSERT INTO ACCOUNT ... SELECT ACCOUNTID, ACCOUNT, MAINPHONE, FAX ... In the middle of the stored procedure, ...
      (microsoft.public.sqlserver.programming)
    • Re: Huge "IF" formula help.
      ... I think you need to completely rewrite your description and include an ... the actual account numbers ... > sungen99's Profile: ... Prev by Date: ...
      (microsoft.public.excel.misc)