inserting data in my DB one to many relation

Hello All,

I have a problem with inserting Data into my Database, my CDT named "class" has {emplyeeID, courseID, status} I want to write the following:
{EmployeeID: 1, CourseID:1, status: "Not started},{EmployeeID:1, courseID:2, status:"In progress"},{EmployeeID:1,courseID:3, status:"Completed"}

but when I check my CDT it writes only the full first row and the rest writes only the courseID.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Since you are writing to an array, you have to pass an array.  If you pass a single (scalar) value, then only the first index in the array will be written to.

    In this use case, I usually pass: repeat(length(pv!class),pv!employee.employeeID).  In other words, for every row in class, write the employeeID.

    One caveat is that you have to include a null check, since length() will not like if you pass a null.

Reply
  • 0
    Certified Lead Developer

    Since you are writing to an array, you have to pass an array.  If you pass a single (scalar) value, then only the first index in the array will be written to.

    In this use case, I usually pass: repeat(length(pv!class),pv!employee.employeeID).  In other words, for every row in class, write the employeeID.

    One caveat is that you have to include a null check, since length() will not like if you pass a null.

Children
No Data