Support > Forums > OpenBots Studio > Insert more than 10000 records into database
Hello,
We are facing a problem because inserting more than 10000 recors into a database, the process takes 6 hours. We are using a for each to insert this data. My question is if there is another way to insert records to database in a faster way.
Thanks
This forum has 317 topics, 687 replies, and was last updated 4 months ago by Nataly Alvarado...
This works for Oracle and other database engines as well.
You should be able to use any custom C# snippet as long as it is supported by the engine (.Net 6 Framework).
In addition, the new "Bulk Insert" command will be able to interact with any OLEDB connection
Hi Nataly,
Thanks for your response. I have one question, this works only with SQL? OR we can do the same with Oracle?
Thanks
Hi ti-distribucion,
You can group the records into a datatable and use a bulk add query to the database. Note that the datatables need to match the exact column names, order and type of the database fields.
To perform the bulk addition, you can use the Evaluate Snippet command, with the following logic:
using (SqlConnection connection = new SqlConnection(vDBConnectionString)) using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connection)) { connection.Open(); bulkCopy.DestinationTableName= "TableName"; bulkCopy.WriteToServer(vDataTableInput); }
In this case, remember to import the corresponding library: System.Data.SQLClient
Also note that in Studio 2.1.0 (not yet released) we are adding a new command to support Bulk Insert based on a datatable input (same functionality as the code shared).
You are not authorized to reply, please click here to login and add your reply to this topic.