By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,227 Members | 1,026 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,227 IT Pros & Developers. It's quick & easy.

[Fwd: Double lock on iseries db2 transaction]

P: n/a

I'm seeing some odd locking behavior when using an DB2400 database and
running an transaction. My code -- in simplified form, appears
at the bottom.

I want to run several INSERT statements using the same iDB2Connection
and iDB2Command. Then I want to Commit() so that either all the data
goes in, or not.

What happens though is this:

1. After the first INSERT, a lock appears on the FILE
2. After the second INSERT, another lock appears on the FILE.
3. I can then add several more records, and no more locks appears
4. After the Commit(), one lock disappears but not the other.

I have run the code with every available IsolationLevel, including the
default, and the result is the same.

My questions are:

1. Where could this second lock come from?
2. Why does Commit() not remove it?
3. What additional properties or commands do I need to account for to
remove this lock?
4. I have read that there may be a journaling property that sets up an
'autocommit/rollback' in the event of a system crash -- could this be
what's causing it?

using System;
using IBM.Data.DB2.iSeries;
using System.Data;
using System.Diagnostics;

namespace simpleTtest
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main(string[] args)
// TODO: Add code to start application here

string connStr= "Data Source=192.168.NNN.NNN;User
Id=XXXXXX;Password=XXXXX;Default Collection=DataLibrary;";
iDB2Connection p_iconn =
new iDB2Connection(connStr);
iDB2Transaction itrans=null;
iDB2Command icmd=new iDB2Command("INSERT INTO " +
"(" +
"W1BATCH)" +
"VALUES('100')", p_iconn);
itrans = p_iconn.BeginTransaction(

//after this statement a lock is generated

//after this statement a second lock appears

//no more locks; there are still two(2) at this point

// after commit, one lock is removed -- one remains! why...?
catch(Exception e)

Texeme Construct

Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.