Forum Discussion

NT's avatar
NT
Contributor
10 years ago

How to refresh a DB Table Variable in a Loop

Hi,   I would like to continue to a second KeywordTests base on a field that is update in a Database.   So in terms of word.   I execute Test1 and would like to execute Test2 only if the Field ...
  • cunderw's avatar
    cunderw
    10 years ago

    Without seeing your setup in person I would do something like this.

     

    At the end of  Test1 Run this script (obviously filling in the details).

     

    function checkStatut() {
      var dbConnection,
          record,
          statut;
      
      dbConnection = ADO.CreateADOConnection();
      dbConnection.ConnectionString = "connectionString"
      dbConnection.LoginPrompt = false;
      dbConnection.Open()
      
      record = dbConnection.Execute_("sql query");
      statut = record.Fields("Statut").Value;
      
      if (statut == "<P>")
    	KeywordTests.Test2.Run(); //assuming Test2 is a keyword test
    }
  • NT's avatar
    NT
    10 years ago
    thanks it work fine, but now if the Statut become at value P only after a certain time so it means that I need to refresh the information of the statut by reading the information in the database until it becomes at value P. It is a delay treatment. is it possible to use a Loop to wait until the statut become at value P ? thanks a lot for your help !!!
  • cunderw's avatar
    cunderw
    10 years ago

    Sure try something like this:

     

    function checkStatut() {
      var dbConnection,
          record,
          statut;
      
      dbConnection = ADO.CreateADOConnection();
      dbConnection.ConnectionString = "connectionString"
      dbConnection.LoginPrompt = false;
      dbConnection.Open()
      
      while (statut != "<P>") {
        record = dbConnection.Execute_("sql query");
        statut = record.Fields("Statut").Value;
      
        if (statut == "<P>")
       	  KeywordTests.Test2.Run(); //assuming Test2 is a keyword test
      }
    }