I have a folder of .sql scripts I want to load into Toad, execute the script, and then export the data table to a .txt file. My sequence of activities to load, execute, and export the data table are working as expected for the first script in the folder, but I can’t get the “For Each” to iterate through the other scripts in the folder and perform the same set of activities (load, execute, & export data).
After passing the input to for each loop with variable GetScripts like
GetScripts = Directory.getFiles(SPath)
, kindly dont forget to change the typeargument type as string as you are getting as string
I can see the first script load, run, and export, but than nothing, so I am not sure it is iterating through the other scripts as I do not see the action being performed on screen. But, shortly after the first script finishes I receive the following message:
@CScruggs
Buddy its not like it didnt get iterated rather it got stuck with a on element appear activity that you have added next to your first scrip load, run and export process…as it took more than 30 seconds to wait for element
Buddy may i know where and why do you use this on element appear, are you using to wait untill an page needs to be loaded or is there any specific reason…Kindly let us know buddy
For each script:
performs the following activities in Toad:
opens folder
gets script file
loads script
runs script (F9) hotkey
invokes get data workflow
Clears All (f7) - for new editor for next script, but the other scripts never load…I get the same error message.
Aahah…then fine buddy…you dont need to go for toad and type hotkeys rathe we have a activity called Execute query activity where you can pass any. sql scripts as string type and get the output table from db as datatable…use the same iteration you have now like inside for each loop remove all the activities and place this single execute query activity and pass the for each loop value as input to this which has the scripts to be run…
You can get this activity by downloading the package system.database.activities…
Okay, I will try this again. The first time I tried the database connect activity I could never get the connection string correct to the database. Also, how can I secure my login credentials? Is there an Encrypt feature in UiPath?
Inside for each loop give the same input as scripts you are right…
Then inside the loop, first use a read text activity with input as scripts (path) and get the output variable a string datatype named out_text
Now use the same private: EXECUTE QUERY activity with same connection strings but with input as out_text (the text read from the path of the file which has the query) Not as “Scripts”
Now if you want you can get the table from this execute query activity in a datatable type to a variable final_dt