<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>get along with Oracle and APEX &#187; SQL</title>
	<atom:link href="http://www.oracle-and-apex.com/category/tipps-tricks/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.oracle-and-apex.com</link>
	<description>by Peter Raganitsch</description>
	<lastBuildDate>Mon, 23 Aug 2010 08:26:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to calculate size of a CLOB in Bytes?</title>
		<link>http://www.oracle-and-apex.com/how-to-calculate-size-of-a-clob-in-bytes/</link>
		<comments>http://www.oracle-and-apex.com/how-to-calculate-size-of-a-clob-in-bytes/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 07:36:33 +0000</pubDate>
		<dc:creator>Peter Raganitsch</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tipps & Tricks]]></category>
		<category><![CDATA[CLOB]]></category>

		<guid isPermaLink="false">http://www.oracle-and-apex.com/?p=122</guid>
		<description><![CDATA[Recently i was dealing with a translation problem regarding multibyte characters (cyrillic). They were stored in a NCLOB and were later on moved to a VARCHAR2.
Before moving the data i had to ensure, that there will be enough space in the VARCHAR2 columns which were defined as VARCHAR2(255 BYTE).
That&#8217;s where my travel started, i had [...]]]></description>
			<content:encoded><![CDATA[<p>Recently i was dealing with a translation problem regarding multibyte characters (cyrillic). They were stored in a NCLOB and were later on moved to a VARCHAR2.</p>
<p>Before moving the data i had to ensure, that there will be enough space in the VARCHAR2 columns which were defined as VARCHAR2(255 BYTE).</p>
<p><span id="more-122"></span>That&#8217;s where my travel started, i had to figure out how many bytes a CLOB-Value would consume when storing in a VARCHAR2 column.</p>
<p><em>LENGTH(&lt;clob-column&gt;)</em> fails, because it returns the number of characters</p>
<p><em>DBMS_LOB.getLength(&lt;clob-column&gt;)</em> fails as well, because it returns number of characters</p>
<p><em>LENGTHB</em> doesn&#8217;t work on CLOBs, so i thought: implicit type conversion, so i came up with this</p>
<p><em>LENGTHB(DBMS_LOB.SUBSTR(&lt;clob-column&gt;,1,2000))</em> this one looked promising, but it failed at the end because it would return the number of bytes this string uses in the CLOB Characterset (which is AL16UTF16)</p>
<p><span style="text-decoration: underline;">The winner is:</span> <strong><em>LENGTHB(TO_CHAR(SUBSTR(&lt;clob-column&gt;,1,4000)))</em></strong> this one really returns the size in bytes the string would consume when stored in a VARCHAR2 column.</p>
<p>Thanks to explicit type conversion!</p>
<img src="http://www.oracle-and-apex.com/blog/?ak_action=api_record_view&id=122&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.oracle-and-apex.com/how-to-calculate-size-of-a-clob-in-bytes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
