COPY-LOB Raw to File

Posted by dpackerSIG on 05-Feb-2019 16:19

Is there any way to copy a RAW to a file and back again?  I'm working on an encryption project and need to save the hashed data, then retrieve it and decrypt the data into plaintext.

Thanks in advance for any help or advice.

-Dan

All Replies

Posted by Peter Judge on 05-Feb-2019 16:28

Put the RAW  data into a MEMPTR variable; COPY-LOB that wherever.
 
def var r1 as raw.
define variable mdata as memptr no-undo.
 
put-string(r1, 1)  = 'abcde'.
 
mdata = r1.
copy-lob mdata to file session:temp-dir + 'raw.out'.
 
set-size(mdata) = 0.
 
 
And you can do the reverse on read. The RAW variable is automatically cleaned up, but you’ll need to manually SET-SIZE() on the MEMPTR to prevent memory leaks.
 
 

This thread is closed