You are not logged in.
I have an XSD which has let's say 100 fields. However, on any given xml file, only two are guaranteed to be there: the ID field and the transaction type. The idea is that I want to either update, insert, or delete a record based on the ID. If it's an update, I want to only update the fields which were passed and not the rest. Is there an easy way to do this?
One option is to lookup against the target to get the existing data for the ID and update the entire record; using the lookup values only if the input is value is null. However, my question is:
How do I distinguish between something that was not sent in the XML vs. something that was sent in the XML but was intentionally sent to null?
Well, there is not an easy way to do this that I can think of, but it is possible to develop this logic in a job. Talend database output objects have static schemas associated with them, so you cannot let the content of the input record drive the update process. E.g. if record1 has only two columns, update two columns, if record2 has 100 columns then update 100 columns.
Your question of "how do I distinguish between something that was not sent in the XML vs. something that was sent in the XML but was intentionally set to null" -- this is an application design question, and not really a question on how to use Talend. If your application is only sending over data that needs to be updated, I am not sure how the application would distinguish trying to set a null value without putting some hardcoded value in the xml that tells it should be null. Since a missing element could be no change or it could mean set it to null. So, I would ask the application designers how they plan to explicitly set null with this design and go from there since a missing element is ambiguous.
To build a dynamic update statement with 100 columns would be a somewhat tedious process, but you could do it. I recommend the lookup approach if that's possible.
Please let me know if you need additional information regarding this. Thanks,