Totally not related to Epicor… But if you wanted to make up a use case, pretend you have QC data in an external DB and want to pull that info into a report in Epicor.
My real case …
I have a BLOB field in a SQL database that holds raw data from a devices memory. I need to access specific data, knowing the offset from the beginning.
For example: imagine my blob (field name Data_Blob
) has the following binary data stored in it
7f 00 0a e3
18 0b 42 bf
83 20 01 fe
00 00 00 5a
91 03 0a f8
It’s all sequential (no line breaks), I added them as every “chunk” of data I need is at a 4 byte interval. And those are just the hex representations of the bytes in the blob.
I need to extract the 18
, 0b
, 42
, and bf
. Prefer getting them one at a time (offsets of 0x004, 0x005, 0x006, and 0x007) But getting one 4-byte number (0x180b42bf) from (0x004) would be okay.
I’ve tried using substring(Data_Blob,4,4), but it returns nothing. Checked to see if substring even returns anything from a blob with
SELECT recID, length(substring(Data_Blob,0,1)) AS SubBlob, Data_Blob FROM `h10_data` ORDER BY `RecID` DESC;
and that returns a big fat zero in the SubBlob field. I’m guessing that the SUBSTRING only works on strings, which only ever have a null char to indicate the end of the string. And with my BLOB having “null’s” in it, SUBSTRING terminates when it hits one. Or it just doesn’t like BLOBs.
Any thoughts on how I can access specific bytes in the BLOB?
And for what its worth, I did do a lot of Googling on this topic. but everything I come across about BLOBs, assumes they are the contents of a file and you’re just storing them and retrieving them. Never doing anything with their actual contents. And every example for “displaying” the contents is based on downloading the contents and then sending them to a viewer for their type (jpeg, png, WAV, etc…)