How to skip a busy record in batch process

Posted by cngarcia on 16-Dec-2016 09:33

I have this batch process that serves as a data switching station between an OE DB in UNIX and MS SQL (back and forth). While there is no one in SQL locking the record it works fine. The batch runs every 5 minutes and its logic is very simple: a FOR EACH looking the SQL records and if it meets the condition they are copied to UNIX, after this the records are marked in SQL as posted. But if, by coincidence, a user from the SQL side traps the record my batch process gets stuck sending and error message to the limbo hanging the program.  This condition locks the system forcing my to abort the batch process.

My question is: how can I skip a record if it is busy and proceed with the next one? I have tried different approaches without success (EXCLUSIVE-LOCK, ERROR-STATUS, CATCH).

Any idea will be appreciated.

Rgds/Carlos Garcia

Posted by cverbiest on 16-Dec-2016 09:50

def buffer alt-record for record.

/* for each no-lock */

for each record no-lock:

/* lock the record without waiting using an alternate buffer */

find alt-record where rowid(alt-record) = rowid(record) excluisve-lock no-wait no-error.

if locked alt-record

then do:

/* report error */

   next.

end.

end.

All Replies

Posted by cverbiest on 16-Dec-2016 09:50

def buffer alt-record for record.

/* for each no-lock */

for each record no-lock:

/* lock the record without waiting using an alternate buffer */

find alt-record where rowid(alt-record) = rowid(record) excluisve-lock no-wait no-error.

if locked alt-record

then do:

/* report error */

   next.

end.

end.

Posted by cngarcia on 16-Dec-2016 12:40

Hi,
 
Sweet! It worked. Thanks!
 
 
Atentamente,
 
laacsign75
Carlos N. García
IT Manager
Tel.:        (787) 848-9000 ext 2901
Fax          (787) 848-0070
 
 

Posted by cngarcia on 16-Dec-2016 13:33

Sweet! It worked. Thanks!

This thread is closed