<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to calculate size of a CLOB in Bytes?</title>
	<atom:link href="http://www.oracle-and-apex.com/how-to-calculate-size-of-a-clob-in-bytes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.oracle-and-apex.com/how-to-calculate-size-of-a-clob-in-bytes/</link>
	<description>by Peter Raganitsch</description>
	<lastBuildDate>Mon, 30 Jan 2012 22:22:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
	<item>
		<title>By: Kiran</title>
		<link>http://www.oracle-and-apex.com/how-to-calculate-size-of-a-clob-in-bytes/comment-page-1/#comment-13716</link>
		<dc:creator>Kiran</dc:creator>
		<pubDate>Fri, 06 Jan 2012 18:59:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.oracle-and-apex.com/?p=122#comment-13716</guid>
		<description>Hi Filippos,
what is the .getblobval which you are using in your query?</description>
		<content:encoded><![CDATA[<p>Hi Filippos,<br />
what is the .getblobval which you are using in your query?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Filippos</title>
		<link>http://www.oracle-and-apex.com/how-to-calculate-size-of-a-clob-in-bytes/comment-page-1/#comment-11910</link>
		<dc:creator>Filippos</dc:creator>
		<pubDate>Wed, 07 Dec 2011 14:19:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.oracle-and-apex.com/?p=122#comment-11910</guid>
		<description>I ran into the same problem, albeit when trying to calculate the length of XMLTYPE contents.
Finally the solution was to write my own function that returns a such a CLOB that LENGTH would always give the correct value !
Just in case it is needed, I will provide my solution here :

create or replace
FUNCTION &quot;BLOB_TO_CLOB&quot; (p_blob IN BLOB) RETURN CLOB
AS

	v_clob          CLOB;
	v_dest_offset   INTEGER := 1;
	v_source_offset INTEGER := 1;
	v_lang_context  INTEGER := DBMS_LOB.DEFAULT_LANG_CTX;
	v_warning       INTEGER := DBMS_LOB.WARN_INCONVERTIBLE_CHAR;
 
BEGIN

	DBMS_LOB.CREATETEMPORARY(v_clob, TRUE);

	DBMS_LOB.CONVERTTOCLOB
	(
		DEST_LOB     =&gt; v_clob,
		SRC_BLOB     =&gt; p_blob,
		AMOUNT       =&gt; DBMS_LOB.LOBMAXSIZE,
		DEST_OFFSET  =&gt; v_dest_offset,
		SRC_OFFSET   =&gt; v_source_offset,
		BLOB_CSID    =&gt; DBMS_LOB.DEFAULT_CSID,
		LANG_CONTEXT =&gt; v_lang_context,
		WARNING      =&gt; v_warning
	);

	RETURN v_clob;

END BLOB_TO_CLOB;

SELECT LENGTH(BLOB_TO_CLOB(.getBlobVal(NLS_CHARSET_ID(&#039;AL32UTF8&quot;)))
  FROM DUAL;</description>
		<content:encoded><![CDATA[<p>I ran into the same problem, albeit when trying to calculate the length of XMLTYPE contents.<br />
Finally the solution was to write my own function that returns a such a CLOB that LENGTH would always give the correct value !<br />
Just in case it is needed, I will provide my solution here :</p>
<p>create or replace<br />
FUNCTION &#8220;BLOB_TO_CLOB&#8221; (p_blob IN BLOB) RETURN CLOB<br />
AS</p>
<p>	v_clob          CLOB;<br />
	v_dest_offset   INTEGER := 1;<br />
	v_source_offset INTEGER := 1;<br />
	v_lang_context  INTEGER := DBMS_LOB.DEFAULT_LANG_CTX;<br />
	v_warning       INTEGER := DBMS_LOB.WARN_INCONVERTIBLE_CHAR;</p>
<p>BEGIN</p>
<p>	DBMS_LOB.CREATETEMPORARY(v_clob, TRUE);</p>
<p>	DBMS_LOB.CONVERTTOCLOB<br />
	(<br />
		DEST_LOB     =&gt; v_clob,<br />
		SRC_BLOB     =&gt; p_blob,<br />
		AMOUNT       =&gt; DBMS_LOB.LOBMAXSIZE,<br />
		DEST_OFFSET  =&gt; v_dest_offset,<br />
		SRC_OFFSET   =&gt; v_source_offset,<br />
		BLOB_CSID    =&gt; DBMS_LOB.DEFAULT_CSID,<br />
		LANG_CONTEXT =&gt; v_lang_context,<br />
		WARNING      =&gt; v_warning<br />
	);</p>
<p>	RETURN v_clob;</p>
<p>END BLOB_TO_CLOB;</p>
<p>SELECT LENGTH(BLOB_TO_CLOB(.getBlobVal(NLS_CHARSET_ID(&#8216;AL32UTF8&#8243;)))<br />
  FROM DUAL;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Quentin Crisp</title>
		<link>http://www.oracle-and-apex.com/how-to-calculate-size-of-a-clob-in-bytes/comment-page-1/#comment-10244</link>
		<dc:creator>Quentin Crisp</dc:creator>
		<pubDate>Wed, 21 Sep 2011 13:42:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.oracle-and-apex.com/?p=122#comment-10244</guid>
		<description>Thanks you are a life saver!</description>
		<content:encoded><![CDATA[<p>Thanks you are a life saver!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Raganitsch</title>
		<link>http://www.oracle-and-apex.com/how-to-calculate-size-of-a-clob-in-bytes/comment-page-1/#comment-3978</link>
		<dc:creator>Peter Raganitsch</dc:creator>
		<pubDate>Mon, 20 Dec 2010 08:17:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.oracle-and-apex.com/?p=122#comment-3978</guid>
		<description>Steve,

is it important to know whether the resulting string contains multibyte characters?

To me it was enough to know, if the resulting string exceeds a certain length, no matter if there are multibyte characters in it, or not.</description>
		<content:encoded><![CDATA[<p>Steve,</p>
<p>is it important to know whether the resulting string contains multibyte characters?</p>
<p>To me it was enough to know, if the resulting string exceeds a certain length, no matter if there are multibyte characters in it, or not.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://www.oracle-and-apex.com/how-to-calculate-size-of-a-clob-in-bytes/comment-page-1/#comment-3916</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Sat, 18 Dec 2010 13:37:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.oracle-and-apex.com/?p=122#comment-3916</guid>
		<description>I still haven&#039;t come up with a good way to determine if a CLOB &gt; 4K contains any multibyte characters.  I ran into many of the same limitations you did above.  I ended up writing a java program that read each character and determined if its code point value was greater than 255.  A really ugly hack.</description>
		<content:encoded><![CDATA[<p>I still haven&#8217;t come up with a good way to determine if a CLOB &gt; 4K contains any multibyte characters.  I ran into many of the same limitations you did above.  I ended up writing a java program that read each character and determined if its code point value was greater than 255.  A really ugly hack.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

