1 Reply Latest reply: Jan 17, 2013 1:29 AM by POPS. RSS

    How to Dynamically construct a CSV and Attach it as Databank

    878316
      Hi,

      I would like to know if it is possible to dynamically construct a csv file and add it to the Script assets as a Databank?

      If so, please kindly let me know.

      Edited by: OATS Explorer on Dec 20, 2012 5:27 AM
        • 1. Re: How to Dynamically construct a CSV and Attach it as Databank
          POPS.
          Hi,

          Hope this code will help you

          String filecontent = "";
          String filepath="C:\OracleATS\OFT\DataBank\Dynamicfile.csv";
                    
          filecontent=filecontent.concat("USER,PASSWORD,DESCRIPTION\n");
          filecontent=filecontent.concat("ABC,Oracle,Testinguser1\n");
          filecontent=filecontent.concat("xyz,Oracle,Testinguser2\n");


          utilities.getFileService().writeStringToFile(filepath, filecontent, true);
               
          getDatabank("DynamicDatabank1").load("Default", "DataBank\Dynamicfile", "startIndex=1");

          info("No.of Records:"+getDatabank("DynamicDatabank1").getDatabankRecordCount());


          for(int i=1;i<=getDatabank("DynamicDatabank1").getDatabankRecordCount();i++)
          {
               getDatabank("DynamicDatabank1").getNextDatabankRecord();
               info("User: {{db.DynamicDatabank1.USER}}");
               info("Password: {{db.DynamicDatabank1.PASSWORD}}");
               info("Description: {{db.DynamicDatabank1.DESCRIPTION}}");
          }


          Thanks
          -POPS