Forum Discussion

pkudrys's avatar
pkudrys
Contributor
2 years ago
Solved

DBTableVariableObj.Reset() not working as expected

Hi guys, 

I'm experiencing a weird problem with DBTableVariableObj.Reset(), which is supposed to reset the iterator back to the first row. Well, it seems it does not reset the iterator at all :) 

Here is a simple function to demonstrate the issue...

//dbTableToRead is a DB Table variable diefined in keyword test
//columnToRead is a name of column
function testDBTableReset(dbTableToRead, columnToRead)
{
  var targetWord, i=1;
  
  // Obtains a DB Table variable
  var dbTable = dbTableToRead;
  
  // Initializes the iterator
  dbTable.Reset;
  
  Log.Message("Iteration - Start");

  // Iterate through rows
  while(!dbTable.IsEOF())
  {
      targetWord = dbTable.Value(columnToRead);
      Log.Message("Row number: " + i.toString() + " Value: " + targetWord);
      
    // Forward the iterator to the next row
    dbTable.Next();
    i++  
  }
  Log.Message("Iteration - End"); 
}

Basically, it should iterate over the items in DB Table variable and write them to log. I'm calling this function two times in the same keyword test...

And here is the result: 

Basically, the second run of the function jumps over the while(!dbTable.IsEOF()) block, as if the dbTable is not reset? But it should be or am I doing something wrong? 

It seems it's not possible to attach the sample project here, so if you are interested, you can get it here (zipped and inspected for viruses):
https://drive.google.com/file/d/1TiRh50vKP6mguNRgvT13-vnyL-eP8rp1/view?usp=sharing

Thank you in advance for any suggestion.