oracle 转码函数
CREATE OR REPLACE FUNCTION base64decode(p_clob CLOB)
RETURN CLOB
IS
l_blob CLOB;
l_raw RAW(32767);
l_amt NUMBER := 7700;
l_offset NUMBER := 1;
l_temp VARCHAR2(32767);
BEGIN
BEGIN
DBMS_LOB.createtemporary (l_blob, FALSE, DBMS_LOB.CALL);
LOOP
DBMS_LOB.read(p_clob, l_amt, l_offset, l_temp);
l_offset := l_offset + l_amt;
l_raw := UTL_ENCODE.base64_decode(UTL_RAW.cast_to_raw(l_temp));
DBMS_LOB.append (l_blob, TO_CLOB(utl_raw.cast_to_varchar2(l_raw)));
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
END;
RETURN l_blob;
END;
oracle 解码函数:
CREATE OR REPLACE FUNCTION base64encode(p_clob CLOB)
RETURN CLOB
IS
l_blob CLOB;
l_raw RAW(32767);
l_amt NUMBER := 7700;
l_offset NUMBER := 1;
l_temp VARCHAR2(32767);
BEGIN
BEGIN
DBMS_LOB.createtemporary (l_blob, FALSE, DBMS_LOB.CALL);
LOOP
DBMS_LOB.read(p_clob, l_amt, l_offset, l_temp);
l_offset := l_offset + l_amt;
l_raw := UTL_ENCODE.base64_encode(UTL_RAW.cast_to_raw(l_temp));
DBMS_LOB.append (l_blob, TO_CLOB(utl_raw.cast_to_varchar2(l_raw)));
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
END;
RETURN l_blob;
END;
java 解码函数
public String decodeStr(String encodeStr){ byte[] b=encodeStr.getBytes(); Base64 base64=new Base64(); b=base64.decode(b); String s=""; try { s = new String(b,"GBK"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } logger.debug("value-------------------------------------:"+s); return s; }