Table of Contents Previous Next


7 Built-In Packages : 7.15 UTL_ENCODE

The UTL_ENCODE package provides a way to encode and decode data.
Use the BASE64_DECODE function to translate a Base64 encoded string to the original RAW value.
Use the BASE64_ENCODE function to translate a RAW string to an encoded Base64 value.
Use the BASE64_ENCODE function to translate a TEXT string to an encoded Base64 value.
Use the MIMEHEADER_DECODE function to translate an encoded MIMEHEADER formatted string to it's original value.
MIMEHEADER_ENCODE(buf, encode_charset, encoding)
Use the MIMEHEADER_ENCODE function to convert and encode a string in MIMEHEADER format.
Use the QUOTED_PRINTABLE_DECODE function to translate an encoded string to a RAW value.
Use the QUOTED_PRINTABLE_ENCODE function to translate an input string to a quoted-printable formatted RAW value.
TEXT_DECODE(buf, encode_charset, encoding)
Use the TEXT_DECODE function to decode a string encoded by TEXT_ENCODE.
TEXT_ENCODE(buf, encode_charset, encoding)
Use the TEXT_ENCODE function to translate a string to a user-specified character set, and then encode the string.
Use the UUDECODE function to translate a uuencode encoded string to a RAW value.
UUENCODE(r, type, filename, permission)
Use the UUENCODE function to translate a RAW string to an encoded uuencode value.
Use the BASE64_DECODE function to translate a Base64 encoded string to the original value originally encoded by BASE64_ENCODE. The signature is:
r is the string that contains the Base64 encoded data that will be translated to RAW form.
This command instructs the server to escape any non-printable characters, and to display BYTEA or RAW values onscreen in readable form. For more information, please refer to the Postgres Core Documentation, available at:
The following example first encodes (using BASE64_ENCODE), and then decodes (using BASE64_DECODE) a string that contains the text abc:
Use the BASE64_ENCODE function to translate and encode a string in Base64 format (as described in RFC 4648). This function can be useful when composing MIME email that you intend to send using the UTL_SMTP package. The BASE64_ENCODE function has two signatures:
This function returns a RAW value or an OID.
r specifies the RAW string that will be translated to Base64.
loid specifies the object ID of a large object that will be translated to Base64.
This command instructs the server to escape any non-printable characters, and to display BYTEA or RAW values onscreen in readable form. For more information, please refer to the Postgres Core Documentation, available at:
The following example first encodes (using BASE64_ENCODE), and then decodes (using BASE64_DECODE) a string that contains the text abc:
Use the MIMEHEADER_DECODE function to decode values that are encoded by the MIMEHEADER_ENCODE function. The signature is:
MIMEHEADER_DECODE(buf IN VARCHAR2)
buf contains the value (encoded by MIMEHEADER_ENCODE) that will be decoded.
The following examples use the MIMEHEADER_ENCODE and MIMEHEADER_DECODE functions to first encode, and then decode a string:
Use the MIMEHEADER_ENCODE function to convert a string into mime header format, and then encode the string. The signature is:
MIMEHEADER_ENCODE(buf IN VARCHAR2, encode_charset IN VARCHAR2 DEFAULT NULL, encoding IN INTEGER DEFAULT NULL)
buf contains the string that will be formatted and encoded. The string is a VARCHAR2 value.
encode_charset specifies the character set to which the string will be converted before being formatted and encoded. The default value is NULL.
encoding specifies the encoding type used when encoding the string. You can specify:
Q to enable quoted-printable encoding. If you do not specify a value, MIMEHEADER_ENCODE will use quoted-printable encoding.
B to enable base-64 encoding.
The following examples use the MIMEHEADER_ENCODE and MIMEHEADER_DECODE functions to first encode, and then decode a string:
Use the QUOTED_PRINTABLE_DECODE function to translate an encoded quoted-printable string into a decoded RAW string.
r contains the encoded string that will be decoded. The string is a RAW value, encoded by QUOTED_PRINTABLE_ENCODE.
This command instructs the server to escape any non-printable characters, and to display BYTEA or RAW values onscreen in readable form. For more information, please refer to the Postgres Core Documentation, available at:
The following example first encodes and then decodes a string:
Use the QUOTED_PRINTABLE_ENCODE function to translate and encode a string in quoted-printable format. The signature is:
r contains the string (a RAW value) that will be encoded in a quoted-printable format.
This command instructs the server to escape any non-printable characters, and to display BYTEA or RAW values onscreen in readable form. For more information, please refer to the Postgres Core Documentation, available at:
Use the TEXT_DECODE function to translate and decode an encoded string to the VARCHAR2 value that was originally encoded by the TEXT_ENCODE function. The signature is:
TEXT_DECODE(buf IN VARCHAR2, encode_charset IN VARCHAR2 DEFAULT NULL, encoding IN PLS_INTEGER DEFAULT NULL)
buf contains the encoded string that will be translated to the original value encoded by TEXT_ENCODE.
encode_charset specifies the character set to which the string will be translated before encoding. The default value is NULL.
encoding specifies the encoding type used by TEXT_DECODE. Specify:
UTL_ENCODE.BASE64 to specify base-64 encoding.
UTL_ENCODE.QUOTED_PRINTABLE to specify quoted printable encoding. This is the default.
The following example uses the TEXT_ENCODE and TEXT_DECODE functions to first encode, and then decode a string:
Use the TEXT_ENCODE function to translate a string to a user-specified character set, and then encode the string. The signature is:
TEXT_DECODE(buf IN VARCHAR2, encode_charset IN VARCHAR2 DEFAULT NULL, encoding IN PLS_INTEGER DEFAULT NULL)
buf contains the encoded string that will be translated to the specified character set and encoded by TEXT_ENCODE.
encode_charset specifies the character set to which the value will be translated before encoding. The default value is NULL.
encoding specifies the encoding type used by TEXT_ENCODE. Specify:
UTL_ENCODE.BASE64 to specify base-64 encoding.
UTL_ENCODE.QUOTED_PRINTABLE to specify quoted printable encoding. This is the default.
The following example uses the TEXT_ENCODE and TEXT_DECODE functions to first encode, and then decode a string:
7.15.9 UUDECODE
Use the UUDECODE function to translate and decode a uuencode encoded string to the RAW value that was originally encoded by the UUENCODE function. The signature is:
Note: If you are using the Advanced Server UUDECODE function to decode uuencoded data that was created by the Oracle implementation of the UTL_ENCODE.UUENCODE function, then you must first set the Advanced Server configuration parameter utl_encode.uudecode_redwood to TRUE before invoking the Advanced Server UUDECODE function on the Oracle-created data. (For example, this situation may occur if you migrated Oracle tables containing uuencoded data to an Advanced Server database.)
The uuencoded data created by the Oracle version of the UUENCODE function results in a format that differs from the uuencoded data created by the Advanced Server UUENCODE function. As a result, attempting to use the Advanced Server UUDECODE function on the Oracle uuencoded data results in an error unless the configuration parameter utl_encode.uudecode_redwood is set to TRUE.
However, if you are using the Advanced Server UUDECODE function on uuencoded data created by the Advanced Server UUENCODE function, then utl_encode.uudecode_redwood must be set to FALSE, which is the default setting.
r contains the uuencoded string that will be translated to RAW.
This command instructs the server to escape any non-printable characters, and to display BYTEA or RAW values onscreen in readable form. For more information, please refer to the Postgres Core Documentation, available at:
The following example uses UUENCODE and UUDECODE to first encode and then decode a string:
7.15.10 UUENCODE
Use the UUENCODE function to translate RAW data into a uuencode formatted encoded string. The signature is:
UUENCODE(r IN RAW, type IN INTEGER DEFAULT 1, filename IN VARCHAR2 DEFAULT NULL, permission IN VARCHAR2 DEFAULT NULL)
r contains the RAW string that will be translated to uuencode format.
type is an INTEGER value or constant that specifies the type of uuencoded string that will be returned; the default value is 1. The possible values are:
filename is a VARCHAR2 value that specifies the file name that you want to embed in the encoded form; if you do not specify a file name, UUENCODE will include a filename of uuencode.txt in the encoded form.
permission is a VARCHAR2 that specifies the permission mode; the default value is NULL.
This command instructs the server to escape any non-printable characters, and to display BYTEA or RAW values onscreen in readable form. For more information, please refer to the Postgres Core Documentation, available at:
The following example uses UUENCODE and UUDECODE to first encode and then decode a string:

7 Built-In Packages : 7.15 UTL_ENCODE

Table of Contents Previous Next