この関数を使用できます(この回答 の逆 ):
CREATE FUNCTION blob_to_clob(
value IN BLOB,
charset_id IN INTEGER DEFAULT DBMS_LOB.DEFAULT_CSID,
error_on_warning IN NUMBER DEFAULT 0
) RETURN CLOB
IS
result CLOB;
dest_offset INTEGER := 1;
src_offset INTEGER := 1;
lang_context INTEGER := DBMS_LOB.DEFAULT_LANG_CTX;
warning INTEGER;
warning_msg VARCHAR2(50);
BEGIN
DBMS_LOB.CreateTemporary(
lob_loc => result,
cache => TRUE
);
DBMS_LOB.CONVERTTOCLOB(
dest_lob => result,
src_blob => value,
amount => LENGTH( value ),
dest_offset => dest_offset,
src_offset => src_offset,
blob_csid => charset_id,
lang_context => lang_context,
warning => warning
);
IF warning != DBMS_LOB.NO_WARNING THEN
IF warning = DBMS_LOB.WARN_INCONVERTIBLE_CHAR THEN
warning_msg := 'Warning: Inconvertible character.';
ELSE
warning_msg := 'Warning: (' || warning || ') during BLOB conversion.';
END IF;
IF error_on_warning = 0 THEN
DBMS_OUTPUT.PUT_LINE( warning_msg );
ELSE
RAISE_APPLICATION_ERROR(
-20567, -- random value between -20000 and -20999
warning_msg
);
END IF;
END IF;
RETURN result;
END blob_to_clob;
/
次に、CLOB_TO_BLOB
がある場合 この回答
からの関数 およびデータ:
CREATE TABLE table_name ( value BLOB );
INSERT INTO table_name (value ) VALUES ( CLOB_TO_BLOB( 'abcdefg' ) );
次に:
SELECT BLOB_TO_CLOB( value ) FROM table_name;
出力:
db <> fiddle こちら