CLOB to BLOB (RESOLVED)

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
User avatar
lawingo
Posts: 55
Joined: Fri Dec 04, 2015 6:41 am

CLOB to BLOB (RESOLVED)

Post by lawingo » Wed Mar 11, 2020 8:11 am

I have images stored as CLOB data in a database file. Currently to display this CLOB data on the web I have a routine that disassembles the string and reassembles it using 65k chunks. I then set the image on the screen:

Code: Select all

#ExitPhoto.CurrentItem.Image <= #SYS_APPLN.CreateBitmap( #Base64 )
Everything works like a charm.

Now - I would like to start converting this CLOB data into a BLOB datatype field. BLOBs are so much easier to use with third party reporting software (and just in general).
I looked through the forum and found a nifty utility #SYS_WEB.CreateBlob. My thinking was as I am breaking this CLOB data out and reassembling it into a base64 string I could save the Base64 string as a Blob using this new utility. It doesn't work and was hoping someone could help me find out why.

Code:

Code: Select all

#W_BLOB := #SYS_WEB.CreateBlob( #Base64 "image/png" )
Failure is on that line of code.
Error: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.

I know the base64 string is valid because the images are created on the screen (if I leave this new code out). I'm not sure what " 'atob' on 'Window' " is.

I'm thankful for your help.

-Chad-
Sherrill Furniture Company
Last edited by lawingo on Thu Mar 12, 2020 1:18 am, edited 1 time in total.

User avatar
lawingo
Posts: 55
Joined: Fri Dec 04, 2015 6:41 am

Re: CLOB to BLOB

Post by lawingo » Thu Mar 12, 2020 1:17 am

So I got it working. I had to remove the header info(data:image/png;base64,) from the CLOB String to get the encoding correct.

Just in case someone else out there has set up your DB to capture images with CLOBs and you would like to convert to BLOB here is your code:

Code: Select all

#listcount := #base64.CurChars
#base64 := #base64.Substring( 23 #listcount )
#W_BLOB := #SYS_WEB.CreateBlob( #Base64 'image/png' )
Best,
Chad

Post Reply