How to loop for datatable in electroneek studio

I am executing a select query to get the data from sql datatable and trying to loop for it and based on the data need to to certain steps on web browser. As there is not loop activity available for datatable so don’t know how to proceed in this. and also why we don’t have variables datatypes in studio ?

2 Likes

@AnkitDwivedi Once you get data from database store it in a variable then You can use do…while… activity to loop through this data and perform specific task.

For data types we have number and string. based on Variable value it will identify whether its number or string. however You can also use javascript syntax to convert data types.
image

2 Likes

@Kudlappa_Gouder - Can’ t we add simple for loop activity in the studio functionality ? As this is complex and unnecessary activities adding making it clumsy. It is a suggestion to add these user friendly activities like below.

  • Giving option to add any type of variable.
  • normal for loop
  • try catch block
  • stop activity to stop the bot after any step

As these activities are available in all other automation/RPA tools and that make them easy to utilize it.

1 Like

@AnkitDwivedi I will forward these suggestions to product team and some of them are already in our pipeline. Also for the loop, i don’t see much difference between having ‘for loop’ and ‘do…while…’ in both activities we need to provide same information such as 1.initializing variable value 2.providing condition to exit the loop 3. incrementing the value.

On my personal opinion, its just change in the terms used for activities (if you compare with other RPA) but logic should work same.

Hi @AnkitDwivedi, These are really great suggestions and we appreciate you explaining and breaking them down. We can definitely see how these suggestions could be beneficial in the future.

@Mabwa_Neek - it’s my pleasure.
@Kudlappa_Gouder - I am still not sure how to loop with Do-while loop for datatable. Could you please provide me a sample file with datatable loop. Inn that I should be able to get the respective row or any cell value.

Hi @AnkitDwivedi!
You need to open connection to database before a loop and then you can query data extraction from sql database. I use separate variables to set a value for variables for every iteration. The complete query is written to a variable “myquery”.
image

@d.motta - I want to loop for the datatable result not for the any numeric number. Basically my requirement is to get the data from database table and loop it for all the rows.

@AnkitDwivedi You need to calculate a length of the table (the number of rows in the table) and use a counter (in my example its variable "i’) for rows. Then you use activity for every iteration (for example, its “Read Excel row” activity).