Data Insertion in table | DML Operation | X++ Language

 


scenario

We have a table EmployeeTable. This table is look like below.

EmpIdEmpNameDeptId
E001Rumman AnsariD001

Task 1: You have to insert a row inside the table.

Task 2: Copy all the DeptId from the Dept Table to Employee Table

In this job will insert a row in the EmployeeTable

Below code is solution for the task 1.



static void DataInsertionJob(Args _args)
{ 
        EmployeeTable empdet;
        empdet.EmpId = "E002";
        empdet.EmpName = "Osman Ali Sk";
        empdet.DeptId = "D001";
        empdet.insert();
        info("Data Inserted");
}


Below code is solution for the task 2.



static void DataInsertionJob(Args _args)
{ 
       EmployeeTable empdet;
       DepartmentMy dept; 

        insert_recordset empdet (DeptId)
            select DeptId from dept;
        
       info("Data Copied");

      }
}

Comments