Oracle TO_BLOB(bfile) Function

Oracle TO_BLOB(bfile) is a built-in function that converts a BFILE value to a BLOB value.

Oracle TO_BLOB(bfile) Syntax

Here is the syntax for the Oracle TO_BLOB(bfile) function:

TO_BLOB( bfile [, mime_type] )

Parameters

bfile

Required. The BFILE value to be converted.

mime_type

Optional. It specifies the MIME type set on the resulting BLOB value returned by this function. If mime_type is omitted, no MIME type is set on the BLOB value.

Return Value

The Oracle TO_BLOB(bfile) function returns the BLOB value converted from the given BFILE value.

If any argument is NULL, TO_BLOB(bfile) returns NULL.

Oracle TO_BLOB(bfile) Example

The following hypothetical example returns the BLOB form of the BFILE value in the media_col column of the media_tab table, and sets the MIME type to JPEG on the resulting BLOB.

SELECT TO_BLOB(media_col, 'JPEG')
FROM media_tab;

NULL Parameter

If the argument is NULL, TO_BLOB() returns NULL.

SET NULL 'NULL';
SELECT TO_BLOB(NULL)
FROM dual;

输出:

TO_BLOB(NULL)
________________
NULL

In this example, we use the SET NULL 'NULL'; statement to display NULL values as the string 'NULL'.

Conclusion

Oracle TO_BLOB(bfile) is a built-in function that converts a BFILE value to a BLOB value.