On 09-Nov-2011 12:21 , Albert York wrote:
I need to be able to lock a record in a file in order to do some
testing.

The system that I am testing on does not have an RPG compiler.

Is there a way to lock a record without writing a program?


One method, available with just the OS [since v5r1] and the ability to update a source physical file member [by EDTF if STRSEU is unavailable], follows.

Either SBMJOB the following command string on the CMD() parameter or request the command string from an interactive command line; probably best to remove one of the SQL CALL requests to reflect choice between using interactive or batch:

RUNSQLSTM MySQLsrc SRCMBR(LOCKAROW) COMMIT(*CHG) NAMING(*SYS)

<code>

//DATA /* of source member LOCKAROW of MySQLsrc */
/* Given: a file *LIBL/AA with a column name A */
/* database file *LIBL/AA is journaled */
/* Outcome: active RRN=3 is locked for UPDATE */
/* interactive: held until Enter on DSPRCDLCK */
/* batch: held until 120 seconds have passed */
update aa set a = a
where rrn(aa)=3
;
call qsys/qcmdexc /* if interactive */
('dsprcdlck aa', 0000000012.00000)
;
call qsys/qcmdexc /* for good measure, or instead of dsprcdlck */
('dlyjob dly(120)', 0000000015.00000)
;
rollback
;

</code>

Regards, Chuck

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.