Forum Discussion

Adagio's avatar
Adagio
Frequent Contributor
7 years ago

Refresh the value of a variable

Hello,

 

I have a variable which stores the value of a Database field called 'Status'. I fetch that value by using the connection string and then reading the value from a result set. During the Test run, the Status keeps changing, and I have to check the status and then move ahead with the tests. 

After first block of test run, status changes from 1 to 3

After second block of test run, status changes from 3 to 7

After third block of test run, status changes from 7 to 13.

 

Every time I reuse the variable to compare the value of it, it remains the same as in the beginning, but I was expecting it to change from 1 to 3 to 7 to 13, because the database table has the required status.

 

I'm not sure when I reuse the variable, it makes a fresh call to the DB and gets the status. Looks like it's still fetching the old value.

 

Any suggestion would really be appreciated

 

Thank you

Abhi

 

 

  • You should re-query the table any time you want to check the status.  The result set is not a dynamic read of the table but a "snapshot" of what's there.  

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    You should re-query the table any time you want to check the status.  The result set is not a dynamic read of the table but a "snapshot" of what's there.  

    • Adagio's avatar
      Adagio
      Frequent Contributor

      Thanks Robert! That's what I thought too, and it worked fine.

       

      Thank you very much for help!

       

      Thank you

      Abhi