FileGetNextUniqueRow Function

Action

Sets the test-wide unique row pointer to the row after the current row. If the current row is the last row in a file, the unique row pointer will be reset to the first row. All rows that have not been removed through the function FileRemoveRow or through the parameter bRemoveUsedRow are again available. If no more rows are available, the requesting virtual user is stopped. After the current-row pointer is set with FileGetNextUniqueRow, you can access the columns of the row with the FileGetCol function.

The test-wide unique row pointer is maintained for all virtual users on all agents regardless of whether the file is opened with a regular (FileCSVLoad or FileFixedLoad) or global (FileCSVLoadGlobal or FileFixedLoadGlobal) function. Therefore, all virtual users are essentially sharing test-wide sequential access to the same data file, ensuring that every virtual user gets a unique data row on each FileGetNextUniqueRow function call.

Note: Do not use the FileGetFirstRow, FileGetRow or FileGetNextRow functions when using the FileGetNextUniqueRow function.

After a file has been opened, the file pointer is set to the first row in the first FileGetNextUniqueRow call of the virtual user who makes the call.

Note: Using FileGetRow or FileGetNextRow with FileGetNextUniqueRow may yield unexpected results.

Include file

Kernel.bdh

Syntax

FileGetNextUniqueRow( in hFile          : number 
                      in bRemoveUsedRow : boolean optional ): number;

Return value

row number for the current row (beginning with 1 for the first row of a file)

Parameter Description
hFile Specifies the file handle that is used to access the file
bRemoveUsedRow Optional: Specifies whether used data rows shall be removed. The default value is false. If this parameter is set to true, used data rows are removed in any case. Even if the test execution is stopped due to a lack of data rows. If the parameter is set to false, you can use the function FileRemoveRow to remove rows.

Example

dcltrans                   
  transaction TInit
  begin                          
    if FileCSVLoadGlobal(hFile,"login.csv",",")=false then  
      write("File open error\n");
    end;
    
    FileGetNextUniqueRow(hFile);         
    write("UserName: "+FileGetCol(hFile,1,20)+"\n");
    write("Password: "+FileGetCol(hFile,2,20)+"\n");    
    // Insert here your connection code
  end TInit;
  
  transaction TMain
  begin         
    // Insert here your transaction code
  end TMain;

Sample scripts

UniqueLogin.bdf