Monday, July 9, 2018

RecordSortedList

The RecordSortedList class inserts multiple records in a single database trip,
and can hold a subset of data from a table in a particular sort order that does not
exist as an index.
A
RecordSortedList object holds records from a single table. The list has a
unique key that is defined by the fields listed by using the
sortOrder method.
Records are automatically sorted as they are inserted, they do not have to be
inserted in sort sequence.
RecordSortedList objects are particularly useful for passing a result-set as a
parameter.
There is no limit to the size of a
RecordSortedList object, but they are
completely memory
-based, so there are potential memory consumption problems.
Use a
RecordSortedList in preference to a temporary table when:

Only one sort order is needed.

The number of records is not too high (to avoid memory problems).

Compared to temporary tables,
RecordSortedList objects:

Are faster

Are not disk-based

Only have one index

Cannot be used in forms

Require a call between the client and server per (grouped) read

The following methods are commonly used on
RecordSortedList objects:

del(common) - removes a record that has a key that matches the key
fields in the r
ecordBuffer from the RecordSortedList.

find(common) - sets the recordBuffer to the contents of the record
that has a key that matches the key fields in the
recordBuffer, and
positions the list to the record returned.


first() - positions the list to the first record in the list, and copies its
contents to the
recordBuffer.

ins(common) - inserts a new record in a RecordSortedList, unless it
is a duplicate.


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


len() - returns the current number of records in a RecordSortedListobject.

next() - sets the record buffer to the contents of the next record in theRecordSortedList and positions the list to the record returned.

sortOrder(fieldId, ...) - defines the fields on which the records are
sorted.


sortOrderFromContainer(container) - defines the field(s) on
which the records are sorted.


The following code sample demonstrates how to insert multiple
CustTablerecords in the same database trip, using RecordSortedList.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
RecordSortedList recordSortedList;
CustTable custTable;
recordSortedList = new
RecordSortedList(tablenum(CustTable));
custTable.clear();
custTable.AccountNum = "123";
custTable.CustGroup = "DOM";
custTable.Currency = "USD";
recordSortedList.ins(custTable);
custTable.clear();
custTable.AccountNum = "456";
custTable.CustGroup = "DOM";
custTable.Currency = "USD";
recordSortedList.ins(custTable);
custTable.clear();
custTable.AccountNum ="789";
custTable.CustGroup ="INT";
custTable.Currency ="USD";
recordSortedList.ins(custTable);
recordSortedList.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...