本篇内容主要讲解“Oracle blob类型数据怎么转换成base64编码”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“O...
本篇内容主要讲解“Oracle blob类型数据怎么转换成base64编码”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Oracle blob类型数据怎么转换成base64编码”吧!
需求大概是这样的
base64编码列表的Json格式字符串,图片文件格式是jpg,形如:
"[{"employ_files": "/9j/4AAQSkZJRgABAQEAYABgAAD"},{"employ_files": "/9j/4AAQSkZJRgABAQEAYABgAAD"}]"
其中employ_files是必填子项
CREATE OR REPLACE FUNCTION base64encode(p_blob IN BLOB)
RETURN CLOB
-- -----------------------------------------------------------------------------------
-- File Name : https://oracle-base.com/dba/miscellaneous/base64encode.sql
-- Author : Tim Hall
-- Description : Encodes a BLOB into a Base64 CLOB.
-- Last Modified: 09/11/2011
-- -----------------------------------------------------------------------------------
IS
l_clob CLOB;
l_step PLS_INTEGER := 12000; -- make sure you set a multiple of 3 not higher than 24573
BEGIN
FOR i IN 0 .. TRUNC((DBMS_LOB.getlength(p_blob) - 1 )/l_step) LOOP
l_clob := l_clob || UTL_RAW.cast_to_varchar2(UTL_ENCODE.base64_encode(DBMS_LOB.substr(p_blob, l_step, i * l_step + 1)));
END LOOP;
RETURN l_clob;
END;
/
到此,相信大家对“Oracle blob类型数据怎么转换成base64编码”有了更深的了解,不妨来实际操作一番吧!这里是捷杰建站网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!