Hello... Am developing a web application where granite blocks are to be traced.. The main blocks are cut into cut-blocks at first.. Then these cut-blocks are converted to slabs.. I use two tables here:

1. cutblockdata contains the data of cut-block.
2. slabcutblockdata contains the data of slabs.

My code:

ResultSet rc=st.executeQuery("select DISTINCT APP.CUTBLOCKDATA.* from APP.CUTBLOCKDATA,APP.SLABCUTBLOCKDATA where APP.CUTBLOCKDATA.CBID<>APP.SLABCUTBLOCKDATA.CBID)" );

while(rc.next())
{
RowCount++;
}
System.out.println("ROWCOUNT: "+RowCount);


Suppose i have 3 cut-blocks. For the first time my output for the above query is:

ROWCOUNT:0

Now I convert cut-block1 into slab. Executing the query again my output is:

ROWCOUNT:2

"2" indicates that there are remaining 2 cut-blocks. The output is correct here.

But.. When I convert cut-block2 into slab. Executing the query again my output is:

ROWCOUNT:3

The output is wrong here. I should get ROWCOUNT:1

For the first two times my query is getting executed properly.. But not for the rest of the times.. I need to resolve it quickly too.. Please help.. Thanks in advance..