02-27-2006 04:22 PM
You make a good point, tst. Maybe this reply will bump the thread up and get some attention from someone at NI?
I was kinda surprised myself that it worked. It even behaved sensibly when the input array was of the wrong size.
Input array size < typedef cluster size (including empty array) --> existing array elements mapped to cluster elements, remaining cluster elements set to default values*.
Input array size > typedef cluster size --> first N elements mapped, extra elements ignored.
*default values: I am not sure whether it used the default for the internal boolean datatype (False), or whether it used the default value from the cluster typedef (also all False in my app). Because of my settings, I didn't exercise this aspect of behavior).
I also verified that the values of the cluster elements used as the "Type" input were ignored -- only their datatype was used.
Anyway, it sure seems like intentional conversion behavior, but perhaps undocumented and un-guaranteed. That is kinda shaky, though I'll probably stick with it for this app which will ultimately be deployed as an executable.
-Kevin P.
02-27-2006 08:02 PM
02-27-2006 08:26 PM
LabVIEW, C'est LabVIEW
02-27-2006 10:07 PM
02-27-2006 10:19 PM
02-28-2006 02:19 AM
The wire would be broken because LV is strictly typed - once a wire has a certain data type (e.g. the 1 element cluster) you can't connect another type into the same wire. As was originially suggested, you need to convert it to a variant.
The Insert Data VI uses a variant as an input with a parser inside it to convert to DB data types. To accept more than one element it parses the input cluster or array. This means that If you only have strings you can build an array out of them and wire that array into the Insert Data VI or use JP's method.
What I would suggest, however, is to work in a different way. Normally, when working with DBs, the DB should be designed to fit the data. The user should not update records in the DB but work on the data. That is, you would have a single VI which would accept input X and perform task Y. This usually makes programs more portable and readable but requires some more work to implement, especially in your case.
02-28-2006 04:08 AM
02-28-2006 04:41 AM
Wait a minute... I think I understand the problem better now.
You have a single cluster to account for all the tables in your DB? That's really unnecessary.
Even without changing your DB design to reflect the data structure instead of the UI you could still use more than one cluster. For example, create a VI which will update table X. The VI will have a UI cluster of the appropiate size and will also know which names to call. You need to create such VIs (or tab pages or any other similar device) for every table in your DB and then you won't have to bother with hiding and selecting elements and so on - just open the VI which updates the table you need.
If this doesn't help you, you should post your actual code, preferably only the part of it which deals in this cluster\array and in 7 or 7.1 format.
BTW, why can't you just extract the selected elements from your array (example attached) and wire that array into the Insert Data VI?
02-28-2006 04:59 AM
02-28-2006 08:34 AM
Have you considered inserting into your database using a sql command instead of a cluster. Parsing a sql command is very easy to modify since it is a simple string. Building a complex string is much easier (in my opinion) and flexable than trying to handle clusters or variants.
Paul