preloader-matrix

Alfasith

insert_recordset in dynamic AX – Insert all the records to duplicate table.

Hi,

Normally we used to insert the record like below to transfer the record from 1 table to another.

SourceTableName SourceTbl;
DestinationTableName DestinationTbl;
int records;
ttsBegin;
while select * from SourceTbl
    where SourceTbl.tabId > 0
{
    DestinationTbl.Field1        = SourceTbl.Field1;
    DestinationTbl.Field2       = SourceTbl.Field2;
    DestinationTbl.Field3        = SourceTbl.Field3;
    //So on fields… but it should n=match with datatype / EDT /Enum
    DestinationTbl.insert();
    records++;
}
ttsCommit;
info(records);
/********************************************/
but AX there is another feature to insert the bulk of record without transmission delay in reduced set of codes.

Same above code is reduced to.

insert_recordset DestinationTbl 
select SourceTbl
// where SourceTbl.Feild1 <= 100 
// If you have any condition to filter else al the record will be transfer
 /*****************************************************/
If you want to map the fields you need to.
insert_recordset DestinationTbl (Feild1, Feild2, Feild3...)
    select Feild1, Feild2, Feild3... 
from SourceTbl
where SourceTbl.Feild1 <= 100; //if condition

Regards,


One Response

Leave a Reply

Your email address will not be published. Required fields are marked *