fhg
Volume 9, Number 1 -- January 7, 2009

Bypassing a Locked Record, Take Two

Published: January 7, 2009

Hey, Ted:

I have a slightly different solution to the locked record problem your friends tackled in Bypassing a Locked Record. Like them, I have RPG programs that sequentially read a file and update some of the records. When a program tries to read a record that another job has locked, I sometimes bypass the locked record. Here's how.

Notice the READ operation in the second calculation of this example:

FSomeFile  UF   E           K Disk    Prefix(SR_)
                                                 
D Forever         S               N   inz(*On)   
D Open            C                   Const(' ') 
D Closed          C                   Const('Z') 
                                                 
 /Free                                           
     DoW Forever;                                
         Read(E) SomeRec;                        
         If %Eof(SomeFile);                      
             Leave;                              
         EndIf;                                  
         If %Error();                            
             Read(N) SomeRec;                    
             Iter;                               
         EndIf;                                  
         If SR_Status = Open and SR_Balance = *Zero; 
            Eval SR_Status = Closed;             
            Update SomeRec %Fields(SR_Status);   
         EndIf;                                  
     EndDo;                                      
     Eval *InLR = *On;                           
     Return;                                     
 /End-Free           

The READ includes an E extender, which tells the RPG compiler not to stop if the read ends in error. After the READ and the usual check for end-of-file, I use the %ERROR built-in function to trap the locked records. If the read failed, I read again, but this time without a lock. This second read allows me to move the file pointer to the next record.

In this example, I didn't verify that the read error was caused by a lock. If you need to get that granular, check the %STATUS built-in function for a value of 1218.

Thanks for writing about record locking. It's a big deal in my shop.

--Don


Thanks for the example, Don. We've run several tips about record locking, and I have more to cover when I can get to it.

--Ted


RELATED STORIES

Bypassing a Locked Record

Avoiding Record Locks in RPG

CL-Like Error Handling in RPG

Readers Insights and Feedback: Dealing with Record Locks

Release That Record Lock!



                     Post this story to del.icio.us
               Post this story to Digg
    Post this story to Slashdot


Sponsored By
HELP/SYSTEMS

                                                 SEQUEL
                                                 IBM® System i® Data Access Made Easy

                                              · Complete management access to critical data
                                              · Easy to use by IT and end users
                                              · Automated data access and display
                                              · Comprehensive BI package: reports, tables,
                                                 key performance indicators, and dashboards
                                              · System i-centric for real-time data analysis
                                              · Expert support and training

Click here for a FREE Information Kit!


Senior Technical Editor: Ted Holt
Technical Editor: Joe Hertvik
Contributing Technical Editors: Edwin Earley, Brian Kelly, Michael Sansoterra
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.

Sponsored Links

New Generation Software:  Run IBM Query/400 from your Windows desktop!
Bug Busters Software Engineering:  High availability software that won't break the bank
COMMON:  Join us at the 2009 annual meeting and expo, April 26-30, Reno, Nevada


 

IT Jungle Store Top Book Picks

Easy Steps to Internet Programming for AS/400, iSeries, and System i: List Price, $49.95
Getting Started with PHP for i5/OS: List Price, $59.95
The System i RPG & RPG IV Tutorial and Lab Exercises: List Price, $59.95
The System i Pocket RPG & RPG IV Guide: List Price, $69.95
The iSeries Pocket Database Guide: List Price, $59.00
The iSeries Pocket Developers' Guide: List Price, $59.00
The iSeries Pocket SQL Guide: List Price, $59.00
The iSeries Pocket Query Guide: List Price, $49.00
The iSeries Pocket WebFacing Primer: List Price, $39.00
Migrating to WebSphere Express for iSeries: List Price, $49.00
iSeries Express Web Implementer's Guide: List Price, $59.00
Getting Started with WebSphere Development Studio for iSeries: List Price, $79.95
Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00
Getting Started with WebSphere Express for iSeries: List Price, $49.00
WebFacing Application Design and Development Guide: List Price, $55.00
Can the AS/400 Survive IBM?: List Price, $49.00
The All-Everything Machine: List Price, $29.95
Chip Wars: List Price, $29.95


 
The Four Hundred
Now What?

IT Doing Better Than Other Careers in 2009

Strengthening Dollar Whacks Oracle's Second Fiscal Quarter

As I See It: The Rhythm of Things Unseen

Uncle Sam to Stop Buying Used IT Gear?

Four Hundred Stuff
Safestone Gives i Security Officers Greater Control

SPSS to Update ShowCase OLAP Server Technology

Rand McNally Keeps Truckers On the Go and In the Know

The Who's and What's of ESBs and eSBs

Mohawk Slashes Report Delivery Times, Thanks to Centerfield

Four Hundred Monitor
Four Hundred Monitor's
Full iSeries Events Calendar

System i PTF Guide
December 27, 2008: Volume 10, Number 52

December 20, 2008: Volume 10, Number 51

December 13, 2008: Volume 10, Number 50

December 6, 2008: Volume 10, Number 49

November 29, 2008: Volume 10, Number 48

November 22, 2008: Volume 10, Number 47

TPM at The Register
VCs still pump dough into green tech, renewable energy

Companies burying themselves in IT gear

Linux: this year's silver lining?

Server racket to slow in 2009?

Big Blue urged to open Notes and Domino

Data center budgets to stay course in 2009?

New Unisys CEO tightens the belt

Sun boosts OpenSolaris on Atom

VMware piles up next virtual stack for servers

Supermicro does micro server for SOHOs

Red Hat shakes off economic meltdown

UBS says IT spending in Europe, US to drop 2 per cent in 2009

Visionman launches Nehalem Core i7 servers

American IT staffing will not tank in Q1

THIS ISSUE SPONSORED BY:

Help/Systems
WorksRight Software
MKS


Printer Friendly Version


TABLE OF CONTENTS
Bypassing a Locked Record, Take Two

Be Specific When Updating With SQL Cursors

Admin Alert: Looking for i5/OS Trouble, Part I

Four Hundred Guru

BACK ISSUES

From the IT Jungle Forums
Insert via Java

iSeries Access for Web

Mimix installation and configuration docs

EDI Inovis Programmer - Heavy Duty Problem Solver - Anytime

Data Queues vs. MQ Series: Performance

Removing blanks from a CL Variable

XML




 
Subscription Information:
You can unsubscribe, change your email address, or sign up for any of IT Jungle's free e-newsletters through our Web site at http://www.itjungle.com/sub/subscribe.html.

Copyright © 1996-2009 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement