Monday, July 9, 2018

RecordInsertList

The RecordInsertList class provides array insert capabilities in the kernel. This
allows you to insert more than one record into the database at a time, which
reduces communication between the application and the database.
Records are inserted only when the kernel finds the time appropriate, but they are
inserted no later than the call to the
add() and insertDatabase() methods. These
same methods also return the accumulated number of records that are currently
inserted, which allows you to keep track of when the records are actually
inserted.
The array insert operation automatically falls back to classic record-by-record
inserts when non-SQL based tables are used (for example, temporary tables), or
when the insert method on the table has been overridden.


RecordInsertList is similar to RecordSortedList, but it has built-in client/server
support (it automatically packs data from one tier to another when needed), and it
lacks the sort order features available in
RecordSortedList.
The following methods are commonly used on
RecordInsertList objects:

add(common) - inserts a new record in a RecordInsertList.

insertDatabase() - inserts multiple records on a single trip to the
database.


The following is an example using
RecordInsertList to copy a bill of materials
(BOM) from one BOM to another.



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
void copyBOM(BOMId _fromBomId, BOMId _toBomId)
{
  RecordInsertList bomList;
  BOM bom, newBom;
  bomList = new 
  RecordInsertList(tableNum(BOM));
  while select bom
     where bom.BOMId == _fromBomId
  {
    newBom.data(bom);
    newBom.BOMId = _toBomId;
    bomList.add(newBOM);
  }
  bomList.insertDatabase();
}

Best Regards,
Hossein Karimi

No comments:

Post a Comment

Configure the Firewall on the Enterprise Portal Server

After you install Enterprise Portal, enable Web Server (HTTP) in Windows Firewall. If you do not enable the web server in Windows Firewall...