2023-01-11

[Oracle]BLOB_TO_CLOB

  FUNCTION BLOB_TO_CLOB(P_DATA IN BLOB) RETURN CLOB AS
    L_CLOB         CLOB;
    L_DEST_OFFSET  PLS_INTEGER := 1;
    L_SRC_OFFSET   PLS_INTEGER := 1;
    L_LANG_CONTEXT PLS_INTEGER := DBMS_LOB.DEFAULT_LANG_CTX;
    L_WARNING      PLS_INTEGER;
  BEGIN
  
    DBMS_LOB.CREATETEMPORARY(LOB_LOC => L_CLOB, CACHE => TRUE);
  
    DBMS_LOB.CONVERTTOCLOB(DEST_LOB     => L_CLOB,
                           SRC_BLOB     => P_DATA,
                           AMOUNT       => DBMS_LOB.LOBMAXSIZE,
                           DEST_OFFSET  => L_DEST_OFFSET,
                           SRC_OFFSET   => L_SRC_OFFSET,
                           BLOB_CSID    => DBMS_LOB.DEFAULT_CSID,
                           LANG_CONTEXT => L_LANG_CONTEXT,
                           WARNING      => L_WARNING);
  
    RETURN L_CLOB;
  END;

沒有留言:

張貼留言