Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Inserts multiple records on a single trip to the database.
Syntax
public void insertDatabase([Connection connection])
Run On
Called
Parameters
- connection
Type: Connection Class
Remarks
After the call, the list entries remain in the RecordSortedList object.
The RecordSortedList class must be located on the server before the insertDatabase method is called; otherwise, an exception is thrown.
RecIds and other system-maintained fields are not assigned values until the insertDatabase method call is made.
The method reverts to a record by record insert if any of the following conditions are met:
The table is not SQL-stored.
The insert method for the table is overloaded.
The table includes memo or container fields.
Examples
The following example shows how to insert three records in a single database operation.
{
RecordSortedList recordSortedList;
CustTable custTable;
recordSortedList = new RecordSortedList(tablenum(CustTable));
recordSortedList.sortOrder(fieldnum(custTable,AccountNum));
ttsbegin;
// Prepare record #1 for insertion.
custTable.AccountNum = '1000';
custTable.CreditMax = 10000.0;
recordSortedList.ins(custTable);
// Prepare record #2 for insertion.
custTable.AccountNum = '2000';
custTable.CreditMax = 500.0;
recordSortedList.ins(custTable);
// Prepare record #3 for insertion.
custTable.AccountNum = '3000';
custTable.CreditMax = 9999999.9;
recordSortedList.ins(custTable);
// All three records inserted in one database operation.
recordSortedList.insertDatabase();
ttscommit;
}