Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Inserting with RecordInsertList

(1) ShareShare
ReportReport
Posted on by 1,552
Hi,

I have a customized table with the following properties:
cache lookup: NotInTTS
Table Group: Transaction
AllowRowVersionChangeTracking: Yes
ValidTimeStateFieldType: None
The insert method doesn't have any code
 
Currently I'm inserting to this table using RecordInsertList  via batch. However i can see that records are being inserted to the table even though the batch is still executing. And the number of records inserted increases each certain amount of time. So it seems InsertToDatabase is not inserting eveything at once, it's inserting each group together. I'm currently importing more than 100,000 record.  At first the were around 240 records then i selected the table in SQL and they suddenly became 790, then 1370 etc..
Shouldn't it insert them all at once or is this normal? or is there a fallback?

i'll put the code in the first comment so that the code appears clearly
 
  • Suggested answer
    Martin Dráb Profile Picture
    233,066 Most Valuable Professional on at
    Inserting with RecordInsertList
    That's correct - the purpose of RecordInsertList is not holding all records in memory and insert them at once. It inserts records in smaller chunks automatically; insertToDatabase() is used at the end to process remaining records that haven't been inserted yet.
     
    If you aren't sure how something should work, you can look into documentation: RecordInsertList Class.
  • junior AX Profile Picture
    1,552 on at
    Inserting with RecordInsertList
    Imagine code starts with run method
    class x extends classZBatch
    {
      private RecordInsertList  recordInsertList = new RecordInsertList(tableNum(TableA));
    
      public void run()
      {
        this.process();
        this.postProcess();
      }
    
      public void postProcess() {
    
        recordInsertList.insertDatabase();
      }
    
      void process() 
      {
        str line;
        const str fieldDelimiter = '\r\n';
        const str recordDelimiter = '\r\n';
        importFile.inFieldDelimiter(fieldDelimiter);
        importFile.inRecordDelimiter(recordDelimiter);
        while (importFile.status() == IO_Status::Ok)
        {
          line = conPeek(importFile.read(), 1);
    
          ttsbegin;
    
          this.processLine(line);
    
          ttscommit;
    
        }
      }
      protected void processLine(str _line) 
      {
        ClassA process = classA::newFromEnumX(EnumX::First);
        process.insertTableA(_line);
        recordInsertList = process.getRecordInsertList();
      }
    }
    
    
    abstract class classA
    {
        private TableA   tableA;
    
        private RecordInsertList recordInsertList = new RecordInsertList(tableNum(TableA));
    
    
        final public void insertTableA(str _line)
        {
    
            tableA.clear();
            // logic to fill table A
            
            recordInsertList.add(tableA);
    
        }
    
    
        public static ClassA newFromEnumX(EnumX _enumX)
        {
            EnumXAtrribute enumXAttribute = new EnumXAtrribute(_enumX);
            return SysExtensionAppClassFactory::getClassFromSysAttribute(classStr(ClassA), enumXAttribute);
        }
    
    
        public RecordInsertList getRecordInsertList()
        {
            return recordInsertList;
        }
    
    
    }
    
    
    class EnumXAtrribute extends SysAttribute implements SysExtensionIAttribute
    {
        EnumX enumX;
    
        public void new(EnumX _enumX)
        {
            super();
    
            enumX = _enumX;
        }
    
        public str parmCacheKey()
        {
            return classStr(EnumXAtrribute) + ';'+ int2str(enum2int(enumX));
        }
    
        public boolean useSingleton()
        {
            return true;
        }
    
    }
    }
    
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,467 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,066 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans