BASE64ENCODE function
BASE64ENCODE is a function that manipulates all string data types (BIT, BLOB, and CHARACTER).
BASE64ENCODE returns a CHARACTER string that contains the base64-encoded version of the source string.
Syntax
BASE64ENCODE returns a CHARACTER string containing a base64 representation of the source string. The source string can be a string of the CHARACTER, BLOB, or BIT data type. If SourceExpression is NULL, the result is NULL.
If SourceExpression is
of CHARACTER type, it is first converted to the UTF-8 code page before
encoding as base64.
If SourceExpression is
of BLOB type, it is encoded as base64 directly, without any prior
changes.
If SourceExpression is of
BIT type, it is first CAST to BLOB before encoding as base64 and so
its length must be a multiple of 8.
Examples
DECLARE original BLOB X'48656c6c6f';
DECLARE encoded CHARACTER BASE64ENCODE(original);
DECLARE decoded BLOB BASE64DECODE(encoded);
DECLARE original CHARACTER 'Hello World!';
DECLARE encoded CHARACTER BASE64ENCODE(original);
DECLARE decoded BLOB BASE64DECODE(encoded);
DECLARE decoded2 CHARACTER CAST(decoded AS CHARACTER CCSID 1208);
DECLARE original BIT B'0010001001000001';
DECLARE encoded CHARACTER BASE64ENCODE(original);
DECLARE decoded BLOB BASE64DECODE(encoded);
DECLARE decoded2 BIT CAST(decoded AS BIT);
DECLARE original CHARACTER 'Hello World!';
DECLARE originalBlob BLOB CAST(original AS BLOB CCSID 819);
DECLARE encoded CHARACTER BASE64ENCODE(originalBlob);
DECLARE decoded BLOB BASE64DECODE(encoded);
DECLARE decoded2 CHARACTER CAST(decoded AS CHARACTER CCSID 819);