[resolved] How can I insert data into a 1 to many field

One Star

[resolved] How can I insert data into a 1 to many field

Hi
I have an entity which looks like this:
<Person>
<FirstName></FirstName>
<LastName></LastName>
<Address></Address>
</Person>
The address field is one too many.
I have two persons who I want to insert:
<Person>
<FirstName>Dries</FirstName>
<LastName>Nuyts</LastName>
<Address>address1</Address>
<Address>address2</Address>
</Person>
<Person>
<FirstName>John</FirstName>
<LastName>Jackson</LastName>
<Address>address3</Address>
<Address>address4</Address>
<Address>address5</Address>
</Person>
How can I achieve this?
Thanks

Dries
Employee

Re: [resolved] How can I insert data into a 1 to many field

Hi,
Assuming "FirstName" and "LastName" is the composed key of your record, you may send:
<Person>
<FirstName>John</FirstName>
<LastName>Jackson</LastName>
<Address>address3</Address>
<Address>address4</Address>
<Address>address5</Address>
</Person>
using a tMDMOutput. This will put address1, address2 and address3 in the record. Note here the "Address" elements contains the full list of address. So if you have this record currently in database:
<Person>
<FirstName>John</FirstName>
<LastName>Jackson</LastName>
<Address>address1</Address>
</Person>
The Address "address1" will be modified to "address3".
One Star

Re: [resolved] How can I insert data into a 1 to many field

Hi Fhaulme
Thanks for your reply!
It seems that i missed something in the online documentation.
I've resolved the issue by selecting "Use Partial Update" and by setting the following settings:
Pivot: "/Person/Address"
Key: "/Child"
Kind regards
Dries
Employee

Re: [resolved] How can I insert data into a 1 to many field

Hi,
You may use partial update to update (append) elements to a existing address elements. If you wish to update the whole collection at once, the solution I proposed should work fine.
One Star

Re: [resolved] How can I insert data into a 1 to many field

Hi Fhualme
Is it possible to use your solution when the amount of addresses varies? Lets say one person has 1 address and another has 20 addresses.
Kind regards
Dries

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Download