09-21-2019 12:16 PM
Hi All,
I have been struggling with Database connectivity update function. I have been looking for information on how to pass data with in other container than cluster.
My problem is that I have 25 fields to update, which contains various data types, but not all of them will be updated in all scenarios. I have studied that cluster can't be dynamically created and I am unable to get array to work as data source for update function. Also this would not work as there are several data types to be updated.
I am passing an array of clusters to my VI, where each cluster contains the field name (Slot) to be updated and the data to be updated (ID). I am parsing each cluster to populate a new array which contains the fields to be updated, but how can I pass the data to be updated as I'm not able to dynamically create the cluster with correct amount of elements ? It seems there needs to be exact amount of elements in the cluster, otherwise error will be thrown.
Updating one by one works fine for a single data type as in below, but my database will be soon updated with "Audit trail" behavior where each update will create a change log and updating 25 columns would create same amount of changes...
How this could be solved ?
Thanks !
-Antti
Solved! Go to Solution.
09-21-2019 12:43 PM
Why not read the current values of all the data in your database and put that into the master cluster? Only update the values you want to change. Then write the entire cluster back in to the database on the update. You are updating everything, but some of those values just happen to be updates with the same value as it was originally.
09-22-2019 03:38 AM - edited 09-22-2019 03:40 AM
See this recent conversation where someone had a similar question about using an array instead of a cluster. I suspect the same easy change will work for you to and then you could pass an array of Variants in place of a cluster.
09-22-2019 09:11 AM
@drjdpowell wrote:
See this recent conversation where someone had a similar question about using an array instead of a cluster. I suspect the same easy change will work for you to and then you could pass an array of Variants in place of a cluster.
Thank you ! That actually solved my problem right away. It's crazy why array was not accepted by the parser by default...