LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Database Parameterized Query prepends array sizes to binary data

Just to add to complexity of databases...

 

When 'database' is used, it almost always refers to a relational database.

 

There are other database paradigms, like graph databases (Neo4J) or time series databased (InfluxData).

 

These are not better, they're just suitable for other situations.

 

People tend to pick a relational database and then coarse their situation in it. Probably violating normal forms, adding to the problem, not to the solution.

 

This is understandable, as relational databases are the easiest accessible from LabVIEW. And also, the others are not. This makes a relational database easiest short term solution, but that doesn't make it a good solution.

0 Kudos
Message 11 of 13
(238 Views)

@tst wrote:

I don't know if you can use the parameterized query VIs for this, as LV flattens the data in the binary case and that includes the prepended length of the array. One option is to create a copy of the VIs, which doesn't do this, but I expect this might complicate you in the future, if NI changes the DB library to restrict access to the VIs.

 

Another option is to build an explicit binary string version of the data and pass that directly into the full query, rather than using a parameterized query. I'm assuming you're using SQL Server and the column type is defined as binary or varbinary, where I know this works. It might work differently in other cases. This would like something like CALL store_img (@image_in=0x01030498fg...). The 0x indicates this will be binary data and then each two chars is the hex value of the byte. This is easy enough to do in LV using Number to Hex String with a width of 2 and then wire the array into a concatenate primitive:

 

Binary_DB_Data_BD.png


 

We basically ended up doing this to insert large amounts of varbinary data into a SQL Server database, but we did have to add in the 4 bytes of size information at the start of the BLOB ourselves:

image.png

 

 

@ The OP... Taking BLOBs out of the database using "Database Variant to Data.vi", you shouldn't see the extra bytes. But if you just use the regular "Variant to Data.vi", you will. That was our experience anyway.

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 12 of 13
(25 Views)

@jmerrill wrote:

...

 

Of course, all the toolkit functions are locked so I cannot help troubleshoot this farther.

The toolkit should not prepend array size to binary parameters.

 


It might be the evaluation software, in my paid version of LabVIEW you can open the Database Connectivity Toolkit VIs. When you see the size getting added to the binary data, how/where are you seeing that happen? 

Jay14159265_1-1731943097138.png

 

 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 13 of 13
(16 Views)