zoukankan      html  css  js  c++  java
  • BLOG图片和CLOG BASE64码的转换

    --BASE64转图片
    CREATE OR REPLACE FUNCTION Decode_Base64(p_Clob_In IN CLOB) RETURN BLOB IS
      v_Blob           BLOB;
      v_Offset         INTEGER;
      v_Tem_Clob       CLOB;
      v_Buffer_Varchar VARCHAR2(32000);
      v_Buffer_Raw     RAW(32000);
      v_Buffer_Size    BINARY_INTEGER := 32000;
    BEGIN
      IF p_Clob_In IS NULL THEN
        RETURN NULL;
      END IF;
      Dbms_Lob.Createtemporary(v_Blob, TRUE);
      v_Offset := 1;
      FOR i IN 1 .. Ceil(Dbms_Lob.Getlength(p_Clob_In) / v_Buffer_Size) LOOP
        Dbms_Lob.Read(p_Clob_In, v_Buffer_Size, v_Offset, v_Buffer_Varchar);
        v_Buffer_Raw := Utl_Encode.Base64_Decode(Utl_Raw.Cast_To_Raw(v_Buffer_Varchar));
        Dbms_Lob.Writeappend(v_Blob, Utl_Raw.Length(v_Buffer_Raw), v_Buffer_Raw);
        v_Offset := i * v_Buffer_Size + 1;
      END LOOP;
      RETURN v_Blob;
    END Decode_Base64;
    
    --图片转BASE64
    CREATE OR REPLACE FUNCTION Encode_Base64(p_Blob IN BLOB) RETURN CLOB IS
      l_Clob CLOB; l_Step PLS_INTEGER := 12000;
    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;
    
    
  • 相关阅读:
    解决express不是内部或外部命令
    spring ioc认识
    Filter编码过滤
    call、apply、bind
    js面向对象浅析
    由clientWidth到document
    401
    删除页面中Form下面隐藏的ViewStatue
    asp.net 下载
    day98
  • 原文地址:https://www.cnblogs.com/ruicccc/p/13227704.html
Copyright © 2011-2022 走看看