title: db2 stored procedure. locking / releasing table
body: <p>I use a stored procedure to read/update/return certain fields in a journaled as400 table. 
  I want to lock the table first and then release it after the record is updated. I 
  tried tons of stuff, but releasing table is a problem. SP defines and opens cursor, 
  selects record into variables and updates the record. I tried 'begin atomic', then 
  lock table in exclusive mode and then when it's over, it doesn't release.
  Is there any statement i missing or do i need to compile it with certain parameters?
  I use a simple create procedure statement in AS400 navigator's sql panel to compile it.
  Will very appreciate some help with example.
  Thanks.</p>