Support > Forums > OpenBots Studio > Insert more than 10000 records into database

Insert more than 10000 records into database

TI Distribucion

  • Reporter
  • Calender Icon July 05,2023 at 5:26 PM

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 314 topics, 681 replies, and was last updated 18 days ago by Support Agent

Nataly Alvarado...

  • Participant
  • Calender Icon July 11,2023 at 3:26 PM

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

TI Distribucion

  • Participant
  • Calender Icon July 10,2023 at 11:24 PM

Hi Nataly,

Thanks for your response. I have one question, this works only with SQL? OR we can do the same with Oracle?

Thanks

Nataly Alvarado...

  • Participant
  • Calender Icon July 10,2023 at 6:53 PM

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.