RE: when to call Insert Database.
Hi,
Insert_Recordset is a keyword in D365 which will be used to insert multiple records at a time. For example, you are looping all the records and inserting records one by one into table using while select, instead of that you can use Insert_Recordset which will increase performance.
InsertDatabase is a part of RecordInsertList functionality.
InsertDatabase will be called after you add all the records to the table buffer and finally call the InsertDatabase.
InsertRecordset is mainly used to increase performance. If you write normal insert, it will call database for each insert.
But if you use InsertRecordSet one single call to the database is enough to all the records that is using InsertDatabase method.
Table1 tempTable1;
Table2 tempTable2;
RecordInsertList insertList = new RecordInsertList(Tablenum(Table2));
While select * from temptable1
{
tempTable2.Field1 = temptable1.Field1;
//add all the buffer value to RecordInsertList using add methiod.
insertList.add(tempTable2);
}
//after the completion of while select and adding all the buffer values to RecordInsertList
call the insertDatabase method to insert all the record at one database call.
insertList.insertDatabase();
Thanks,
Girish S.