cancel
Showing results for 
Search instead for 
Did you mean: 

Base64_encode and data types

justin_willey
Participant
1,209

The v16 & v17 documents (all versions including the SAP Help one) imply that the input to Base64_encode() should be a string - which seems to miss the whole point of the exercise 🙂 In fact it takes a long binary quite happily:

create variable blah1 long binary;
create variable blah2 long varchar;
create variable blah3 long binary;
set blah1 = xp_read_file('c:\\tmp\\mark.tif');
set blah2 = base64_encode(blah1);
set blah3 = base64_decode(blah2);
call xp_write_file('c:\\tmp\\markOUT.tif',blah3 );
with an 8MB tiff

I know that a related issue was discussed in this question back in 2014. But it would avoid a lot of confusion if the documentation for the relevant functions could make it clear when they can handle binary data. (I've just spent some time explaining to someone that thye don't need to convert their binary data to a string so they can convert it to a string so that they .... you get the idea!)

Accepted Solutions (1)

Accepted Solutions (1)

jack_schueler
Product and Topic Expert
Product and Topic Expert

I've recommended an update to the docs to help make this more clear. The difficulty with many of these functions is that they accept arguments of all sorts of types and then convert the input argument to whatever seems to be the most appropriate for that type.

justin_willey
Participant
0 Kudos

Thanks - that's great. Just an indication not to get too hung up on the word "string" would do the job!

Breck_Carter
Participant

FWIW the EXPRTYPE function is useful to answer the question "Just exactly what is the data type at this point?"

For grins and giggles, check the return data type for the STRING() function.

jack_schueler
Product and Topic Expert
Product and Topic Expert

Yikes. That's the function that returns different things based on atmospheric pressure.

Breck_Carter
Participant
0 Kudos

Answers (0)