LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
aartjan

database toolkit support for (mysql) enums

Status: New

What is really nice about the database toolkit is that "database SELECT" variant data can be cast directly into an (array of) cluster using the "database variant to data" function.

aartjan_0-1725964773106.png

However, it cannot cast MySQL enums to Labview enums. By default, MySQL returns the enum string, not the underlying integer. As soon as the casting function encounters a string to cast to an enum, it fails to convert all following data.

My not so elegant workarounds:

- cast the enums in SQL and use "database execute SQL" instead of "database SELECT"

- create a view with the enums converted to int.

 

"database INSERT" does work without hacks: you can use clusters with enums to insert data into MySQL tables. The only caveat there is that LV enums start at zero, whereas MySQL enums start at 1. I work around this by adding an "undefined" value in the Labview enum.

 

My suggestion is to support enums in the database toolkit. After all, in Labview, it is not hard to convert a string into the matching enum.