Find a way to get an IMS segment released after a FIND

First we find to the IMS segment. Following that find is a FIND and update to a DB2 table which also has a triggered stored procedure. The stored procedure is a COBOL program which updates the same IMS database segment record as the find above.

However, every time we run the program the stored procedure transactions hangs in the region. We found that if we remove the call to the IMS segment from the program, the stored procedure can update with issues. But we need data from the IMS segment to use in the program. So to get around the problem, we added a dummy find right after the real find…to force it on to another record and to basically “release” the IMS record.

Question…is there a Natural command or other way to achieve the same thing?

Example code:

FIND (1) IMS-DATABASE WITH IMS-KEY = ‘2’ /* actual find

FIND (1) IMS-DATABASE with IMS-KEY = 'X" /* dummy find added to release the first record

FIND (1) DB2-TABLE with DB2-KEY = ‘3’

I’m not an IMS expert, but it appears that you are holding the IMS record in the calling program preventing the stored procedure from reading that same record causing a dead lock. I’ve seen other tools do something similar – like updating a DB2 table and then calling an ENTIREX or NEON Shadow routine to update the same row. The calling program still has a lock on the table that prevents the ENTIREX/NEON routine from getting access to the the same row and so it just waits. In this example, DB2 is treating the updates from from the calling program and the ENTIREX/NEON routine as two different transactions.

You could try an END TRANSACTION (or COMMIT) or BACKOUT TRANSACTION (or ROLLBACK) after the IMS read. That should release the held IMS record before you get to the DB2 read. Of course the COMMIT or ROLLBACK will also apply to all other database transactions so you have to be careful to not commit or rollback part of your unit-of-work.