LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Database connectivity - dynamic update

Solved!
Go to solution
Highlighted

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...

 

Update One by One.PNG

 

How this could be solved ? 

 

Thanks ! 


-Antti

0 Kudos
Message 1 of 4
(177 Views)

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.

0 Kudos
Message 2 of 4
(164 Views)
Solution
Accepted by topic author AKoksa

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.

0 Kudos
Message 3 of 4
(104 Views)

@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...

0 Kudos
Message 4 of 4
(84 Views)