Hi,
I am currently using dbms_lob.getlength and it returns a number way below the actual size of the file (based on right click file, properties then looking at the size).
I've read that dbms_lob.getlength counts the number of characters and I need to count it in bytes instead. I tried the function provided in AskTom (https://asktom.oracle.com/pls/apex/f?p=100:11:::::P11_QUESTION_ID:9526465800346614914) but the result is closer to the result of dbms_lob.getlength rather than the actual file size. For comparison purposes, the file size is 19517 bytes. While dbms_lob.getlength gives me 18810. This causes a problem for web service POST method (utl_http) Content-Length header.
create or replace function cloblengthb(p_clob in clob ) return number
as
v_temp_blob BLOB;
v_dest_offset NUMBER := 1;
v_src_offset NUMBER := 1;
v_amount INTEGER := dbms_lob.lobmaxsize;
v_blob_csid NUMBER := dbms_lob.default_csid;
v_lang_ctx INTEGER := dbms_lob.default_lang_ctx;
v_warning INTEGER;
v_total_size number := 0; -- Return total clob length in bytes
BEGIN
IF p_clob is not null THEN
DBMS_LOB.CREATETEMPORARY(lob_loc=>v_temp_blob, cache=>TRUE);
DBMS_LOB.CONVERTTOBLOB(v_temp_blob, p_clob,v_amount,v_dest_offset,v_src_offset,v_blob_csid,v_lang_ctx,v_warning);
v_total_size := DBMS_LOB.GETLENGTH(v_temp_blob);
DBMS_LOB.FREETEMPORARY(v_temp_blob);
ELSE
v_total_size := NULL;
END IF;
return v_total_size;
end cloblengthb;
/
Is there a way to get the file size of a CLOB data/variable which is similar to it's size when saved as a text file?