3956: oe_debug_pub.add('get_cto_item_attachment: ' || 'File attachment is null. Nothing to convert to clob... returning null', 1);
3957: return null;
3958: end if;
3959:
3960: l_lob_length := dbms_lob.getlength(l_blob_loc);
3961: l_input_offset := 1;
3962:
3963: DBMS_LOB.CREATETEMPORARY(l_clob_loc, TRUE, DBMS_LOB.SESSION);
3964: DBMS_LOB.OPEN (l_clob_loc, DBMS_LOB.LOB_READWRITE);
3959:
3960: l_lob_length := dbms_lob.getlength(l_blob_loc);
3961: l_input_offset := 1;
3962:
3963: DBMS_LOB.CREATETEMPORARY(l_clob_loc, TRUE, DBMS_LOB.SESSION);
3964: DBMS_LOB.OPEN (l_clob_loc, DBMS_LOB.LOB_READWRITE);
3965:
3966: -- Loop through the blob, and convert and copy to clob in smaller chunks.
3967:
3960: l_lob_length := dbms_lob.getlength(l_blob_loc);
3961: l_input_offset := 1;
3962:
3963: DBMS_LOB.CREATETEMPORARY(l_clob_loc, TRUE, DBMS_LOB.SESSION);
3964: DBMS_LOB.OPEN (l_clob_loc, DBMS_LOB.LOB_READWRITE);
3965:
3966: -- Loop through the blob, and convert and copy to clob in smaller chunks.
3967:
3968: LOOP
3977: ELSE
3978: l_cur_chunk_size := l_lob_length - l_input_offset + 1;
3979: END IF;
3980:
3981: dbms_lob.read(l_blob_loc, l_cur_chunk_size, l_input_offset, l_buf_raw);
3982:
3983: l_buffer := utl_raw.cast_to_varchar2(l_buf_raw);
3984:
3985: -- Write the current chunk.
3982:
3983: l_buffer := utl_raw.cast_to_varchar2(l_buf_raw);
3984:
3985: -- Write the current chunk.
3986: DBMS_LOB.writeappend(l_clob_loc, length(l_buffer), l_buffer);
3987:
3988: -- Increment the input offset by the current chunk size.
3989: l_input_offset := l_input_offset + l_cur_chunk_size;
3990:
3989: l_input_offset := l_input_offset + l_cur_chunk_size;
3990:
3991: END LOOP;
3992:
3993: DBMS_LOB.CLOSE (l_clob_loc);
3994:
3995: return l_clob_loc;
3996:
3997: Exception