× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: [RE: Multi user programming?]
  • From: Raja Rajendren <kgrajen@xxxxxxx>
  • Date: 14 Jul 00 22:15:21 MDT

Buck Calabro <buck.calabro@aptissoftware.com> wrote:

Dear Buck Calabro

I went through your reply and its working fine.  Right now my problem has been
solved.

Thank you for the kind reply.

Regards,
RAJENDREN K. G.
TMSI. INDID.


Raja Rajendren wrote:

>Suppose I'm running a program which is 
>used to edit a record.  Now let us say
>I'm in edit mode, editing a record.  
>And when I try to run the same program in
>one more terminal and try to edit the 
>same record, which is already used by
>one more user, the system shows blank 
>screen with "X" at the bottom.  How to
>rectify this problem.  

In RPG, if your file is opened for Update (like UF on the F-specs), the
record is locked when you do a READ (or its variants READE, etc.) or CHAIN.
The record is unlocked when you move to another record, you use the UNLCK
opcode or update the record via UPDAT or EXCPT.

READ MASTER              - Locks record 1
READ MASTER              - Unlocks record 1, locks record 2
UPDAT MASTER     - Unlocks record 2

If you want to read without locking, specify N in column 43 (RPG/400) or use
the (N) opcode extender (RPG IV) for NO LOCK.  Be aware that if you do this
you cannot update the record you just read - in order to update you must
have a lock on it.

   READ MASTER                  n        - Does not lock record 3
   ...
3 CHAIN MASTER                           - Locks record 3
   UPDAT MASTER                          - Unlocks record 3

These rules are different when you operate under commitment control.

There was a great debate on whether it is good to lock the records or not,
and the outcome was "it depends on your application!"  If you don't lock the
records then you have the possibility of losing data:

JOB 1                                   JOB 2
1   CHAIN MASTER        n               1   CHAIN MASTER        n       
     EXFMTSCREEN                             EXFMTSCREEN
* This job changes the phone number     * This job changes the address
     UPDATMASTER                             UPDATMASTER

If JOB 1 UPDATes first, then JOB 2 will overwrite the phone number with the
one on JOB 2's screen.

If you do lock the records, then all other jobs (including batch) that need
to update record will fall over with a Record in use error.  It is fairly
easy to trap the "Record locked" error using the error indicator and the
file information data structure:

FMaster    UF   E           K Disk                      
F                                     INFDS(MasFeedback)
                                                        
D                SDS                                    
D  StsErrMsg             91    170                      
                                                        
DMasFeedback      DS                                    
D  StsMasStatus     *STATUS 
                                                        
C     MasKey        Chain     RMASTER                            8081

Indicator 80 is "no record found" and indicator 81 is "I/O error occurred."

StsErrMsg contains the error message you would have got had you not used
indicator 81.
StsMasStatus contains the file status - record lock is 01218.  Find these in
the RPG manual under Error Handling.
You can make the record lock error appear faster by doing an OVRDBF xxx
WAITRCD(1)

I hope this helps.

Buck Calabro
Aptis; Albany, NY
"We are what we repeatedly do.
 Excellence, then, is not an act, but a habit." --Aristotle


Billing Concepts Corp., a NASDAQ Listed Company, Symbol: BILL
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.