简体   繁体   中英

How to lock DATAAARA by C API as400

How to lock DATAARA by MI using C API? The lock()/unlock() function only for userspace objects.

The QXXRTVDA() — Retrieve Data Area function is only show information without locking.

The cmd system("ALCOBJ MYDAXXX *DTAARA"); is no wait if dataara already locking from another job.

The current code (is not good)

while(  system("ALCOBJ MYDAXXX *DTAARA ") != 0) {sleep(1);}

You should use lock() MI function, that provides a wait_time argument, defined in QSYSINC/MIH/LOCK. You maybe want to wrap QXXRTVDA() and lock() functions into your own function. Use unlock() to do the reverse. All MI functions are thoroughly described in "ILE C/C++ for AS/400 MI Library Reference, SC09-2418-00" released for V3R7, that's the current book version since November 1996. In that book you'll find useful examples as usual.

You can specify a wait time for ALCOBJ. The wait time is specified in seconds.

ALCOBJ OBJ((MYDAXXX *DTAARA *EXCLRD)) WAIT(60)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM