<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Jiri&#039;s Microblog</title>
	<atom:link href="http://jiri.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jiri.wordpress.com</link>
	<description>few Tips and Tricks I usually discovered the hard way</description>
	<lastBuildDate>Thu, 26 Jan 2012 16:29:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='jiri.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/7ad880719895e756d6ab2c80baa42829?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Jiri&#039;s Microblog</title>
		<link>http://jiri.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://jiri.wordpress.com/osd.xml" title="Jiri&#039;s Microblog" />
	<atom:link rel='hub' href='http://jiri.wordpress.com/?pushpress=hub'/>
		<item>
		<title>The best iPhone car mount under $8</title>
		<link>http://jiri.wordpress.com/2012/01/22/the-best-iphone-car-mount-under-8/</link>
		<comments>http://jiri.wordpress.com/2012/01/22/the-best-iphone-car-mount-under-8/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 20:40:04 +0000</pubDate>
		<dc:creator>jiri</dc:creator>
				<category><![CDATA[other]]></category>
		<category><![CDATA[Random Posts]]></category>
		<category><![CDATA[car holder]]></category>
		<category><![CDATA[car mount]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[magnet]]></category>

		<guid isPermaLink="false">http://jiri.wordpress.com/?p=997</guid>
		<description><![CDATA[I struggled with car mount for my iPhone for a long while. I wanted something easy to use, simple, discrete and cheap. After long search I found it &#8211; magnet mount. I have been using this mount in my car for almost a month and really did not notice any battery drain issues, quality in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=997&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I struggled with car mount for my iPhone for a long while. I wanted something easy to use, simple, discrete and cheap. After long search I found it &#8211; magnet mount.</p>
<p>I have been using this mount in my car for almost a month and really did not notice any battery drain issues, quality in the reception nor GPS issue. It simply works!</p>
<p>1. get magnet car mount, I purchased mine on <a href="http://www.amazon.com/Super-Magnet-Mount-Detector-more-BLK/dp/B001D2E88Y/ref=sr_1_1?ie=UTF8&amp;qid=1327263643&amp;sr=8-1" target="_blank">Amazon</a> under $8, the package includes two disks &#8211; larger is the actual magnet, the smaller is a metal disk</p>
<p><img class="size-medium wp-image-999 alignnone" title="51fkRmsyhVL._SS400_" src="http://jiri.files.wordpress.com/2012/01/51fkrmsyhvl-_ss400_.jpg?w=300&#038;h=300" alt="" width="300" height="300" /></p>
<p>2. mount the magnet on the car dashboard &#8211; it is self-adhesive mount and really takes few seconds</p>
<p><img class="alignnone size-full wp-image-1002" title="IMG_6660" src="http://jiri.files.wordpress.com/2012/01/img_66602.jpg?w=580" alt=""   /></p>
<p>3. open iPhone and put the small metal disk on the inside of the back cover, the disk is self adhesive.I have iPhone 4s and had to use special pentalobe screw driver to open the phone, I purchased the screw driver <a href="http://www.directfix.com/product/IP-2466.html" target="_blank">here</a></p>
<p><img class="alignnone size-full wp-image-1003" title="IMG_6666" src="http://jiri.files.wordpress.com/2012/01/img_6666.jpg?w=580" alt=""   /></p>
<p>4. close the iPhone, you can notice very smell bend where the magnet is</p>
<p><img class="alignnone size-full wp-image-1004" title="IMG_6665" src="http://jiri.files.wordpress.com/2012/01/img_6665.jpg?w=580" alt=""   /></p>
<p>5. the magnet is very strong, it stays in the same position even with charging cable</p>
<p><img class="alignnone size-full wp-image-1005" title="IMG_6662" src="http://jiri.files.wordpress.com/2012/01/img_6662.jpg?w=580" alt=""   /></p>
<p><img class="alignnone size-full wp-image-1006" title="IMG_6663" src="http://jiri.files.wordpress.com/2012/01/img_6663.jpg?w=580" alt=""   /></p>
<p>small note: if you use full cover for your iPhone, you can place the small metal disk inside the case (no need to open the iPhone)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jiri.wordpress.com/997/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jiri.wordpress.com/997/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jiri.wordpress.com/997/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jiri.wordpress.com/997/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jiri.wordpress.com/997/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jiri.wordpress.com/997/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jiri.wordpress.com/997/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jiri.wordpress.com/997/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jiri.wordpress.com/997/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jiri.wordpress.com/997/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jiri.wordpress.com/997/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jiri.wordpress.com/997/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jiri.wordpress.com/997/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jiri.wordpress.com/997/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=997&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jiri.wordpress.com/2012/01/22/the-best-iphone-car-mount-under-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f567ea621740a72d3d6f8de729cb5853?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jiri</media:title>
		</media:content>

		<media:content url="http://jiri.files.wordpress.com/2012/01/51fkrmsyhvl-_ss400_.jpg?w=300" medium="image">
			<media:title type="html">51fkRmsyhVL._SS400_</media:title>
		</media:content>

		<media:content url="http://jiri.files.wordpress.com/2012/01/img_66602.jpg" medium="image">
			<media:title type="html">IMG_6660</media:title>
		</media:content>

		<media:content url="http://jiri.files.wordpress.com/2012/01/img_6666.jpg" medium="image">
			<media:title type="html">IMG_6666</media:title>
		</media:content>

		<media:content url="http://jiri.files.wordpress.com/2012/01/img_6665.jpg" medium="image">
			<media:title type="html">IMG_6665</media:title>
		</media:content>

		<media:content url="http://jiri.files.wordpress.com/2012/01/img_6662.jpg" medium="image">
			<media:title type="html">IMG_6662</media:title>
		</media:content>

		<media:content url="http://jiri.files.wordpress.com/2012/01/img_6663.jpg" medium="image">
			<media:title type="html">IMG_6663</media:title>
		</media:content>
	</item>
		<item>
		<title>Dropbox Referral</title>
		<link>http://jiri.wordpress.com/2012/01/05/dropbox-referral/</link>
		<comments>http://jiri.wordpress.com/2012/01/05/dropbox-referral/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 03:01:26 +0000</pubDate>
		<dc:creator>jiri</dc:creator>
				<category><![CDATA[other]]></category>
		<category><![CDATA[Random Posts]]></category>

		<guid isPermaLink="false">http://jiri.wordpress.com/?p=989</guid>
		<description><![CDATA[Friends, Oracle gurus and all random blog readers. I really love Dropbox, but running slowly out of quota. If you don&#8217;t use Dropbox, want to get free 2GB+250MB bonus (all free) and found at least one of my posts a bit useful, please click on this link http://db.tt/6uSAc28q by clicking and registering, you will help me [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=989&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone" title="dropbox" src="http://blogs-images.forbes.com/tomiogeron/files/2011/10/dropbox_logo.jpeg" alt="" width="140" height="144" /></p>
<p>Friends, Oracle gurus and all random blog readers. I really love Dropbox, but running slowly out of quota. If you don&#8217;t use Dropbox, want to get free 2GB+250MB bonus (all free) and found at least one of my posts a bit useful, please click on this link<a title="http://db.tt/6uSAc28q" href="http://db.tt/6uSAc28q" target="_blank"> http://db.tt/6uSAc28q</a></p>
<p>by clicking and registering, you will help me toget free 250MB as well</p>
<p>Happy 2012!</p>
<p>Jiri</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jiri.wordpress.com/989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jiri.wordpress.com/989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jiri.wordpress.com/989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jiri.wordpress.com/989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jiri.wordpress.com/989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jiri.wordpress.com/989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jiri.wordpress.com/989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jiri.wordpress.com/989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jiri.wordpress.com/989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jiri.wordpress.com/989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jiri.wordpress.com/989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jiri.wordpress.com/989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jiri.wordpress.com/989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jiri.wordpress.com/989/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=989&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jiri.wordpress.com/2012/01/05/dropbox-referral/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f567ea621740a72d3d6f8de729cb5853?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jiri</media:title>
		</media:content>

		<media:content url="http://blogs-images.forbes.com/tomiogeron/files/2011/10/dropbox_logo.jpeg" medium="image">
			<media:title type="html">dropbox</media:title>
		</media:content>
	</item>
		<item>
		<title>Oracle loves Hadoop &#8211; integrate hadoop seamlessly into Oracle</title>
		<link>http://jiri.wordpress.com/2010/07/23/oracle-loves-hadoop-integrate-hadoop-seamlessly-into-oracle/</link>
		<comments>http://jiri.wordpress.com/2010/07/23/oracle-loves-hadoop-integrate-hadoop-seamlessly-into-oracle/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 18:23:05 +0000</pubDate>
		<dc:creator>jiri</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle DML]]></category>
		<category><![CDATA[Oracle External Tables]]></category>
		<category><![CDATA[external table]]></category>
		<category><![CDATA[hadoop]]></category>
		<category><![CDATA[preprocessor]]></category>

		<guid isPermaLink="false">http://jiri.wordpress.com/?p=939</guid>
		<description><![CDATA[Ever wanted to execute hadoop scripts from Oracle environment and join the results to any oracle table? It&#8217;s easier than you think, there is no special tool required, there is no transient (temporary) file created, there is no ETL !! This can be all executed on a fly by any user anytime. Why would you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=939&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to execute hadoop scripts from Oracle environment and join the results to any oracle table? It&#8217;s easier than you think, there is no special tool required, there is no transient (temporary) file created, there is no ETL !! This can be all executed on a fly by any user anytime. Why would you want to do it? Well there can be many reasons, for example you have your customer data stored in oracle and want to join them to very large call files or web longs generated every day.</p>
<p><span style="color:#ffffff;">.</span></p>
<p>Before I explain the trick, let me show you sample print-screen what I mean by &#8220;seamlessly&#8221;. Sample below is a query (in this case executed in DataStudio, but it can be pretty much any client you use to connect to oracle &#8211; SQLPLUS, TOAD, SAS, MS ACCESS, &#8230; you name it), as you can see I run very simple query which in the background goes to remote server, executes hadoop script and returns result back to oracle. User does not need to know that the data reside on non-oracle server (in this case hadoop). Please note the hadoop script is executed on a fly, this is not pre-executed script (it executes every time you run the query).</p>
<p><a href="http://jiri.files.wordpress.com/2010/07/screenshot.png"><img class="size-medium wp-image-940 alignnone" title="Screenshot" src="http://jiri.files.wordpress.com/2010/07/screenshot.png?w=300&#038;h=195" alt="" width="300" height="195" /></a></p>
<h3><span style="color:#ffffff;">.</span></h3>
<h3>What you need</h3>
<p>I used sample VMWARE <a href="http://code.google.com/edu/parallel/tools/hadoopvm/index.html" target="_blank">Hadoop image</a>, I also got Oracle 11.2 Ent on RedHat (this is really nothing special, just standard Oracle install). That&#8217;s all you need. Yup, it&#8217;s that simple.</p>
<h3><span style="color:#ffffff;">.</span></h3>
<h3>Unix setting</h3>
<p>No don&#8217;t worry, there is really no special setting required. The only thing you should do is to exchange public keys between Hadoop and RedHat servers so your ssh won&#8217;t require password. Here is very simple <a href="http://linuxproblem.org/art_9.html" target="_blank">how-to</a></p>
<p>Then create 4 unix directories, you can create just one if you wish, I try to keep things organized.</p>
<pre>/home/jiri/Desktop/sample/data    - this will hold dummy empty file
/home/jiri/Desktop/sample/log     - this will hold oracle logs
/home/jiri/Desktop/sample/bad     - this will hold oracle reject records
/home/jiri/Desktop/sample/execute - this will hold hadoop scripts (wrapped in sh)</pre>
<p>I use sample hadoop script for calculating PI, this script is part of VMWARE image. To execute this script I create two unix scripts on my RedHat Server. As you can see one script is basically simple wrapper, the other calls hadoop script over ssh. Take these as simple examples, there are many ways how to improve them and make them production ready.</p>
<p>/home/jiri/Desktop/sample/execute/run_hadoop.sh</p>
<pre>#!/bin/bash
/home/oracle/Desktop/sample/execute/hadoop_script.sh 2&gt;/dev/null</pre>
<p>/home/jiri/Desktop/sample/execute/hadoop_script.sh &#8211; please change the IP address to your hadoop server IP or host.</p>
<pre>#!/bin/bash
/usr/bin/ssh guest@192.168.149.132 hadoop jar hadoop-examples.jar pi 4 10000</pre>
<p><span style="color:#ffffff;">.</span></p>
<p>the last step is to create dummy empty file  (it&#8217;s really just an empty file, this is dummy file you can reuse for all hadoop scripts)</p>
<pre>/home/jiri/Desktop/sample/data/dummy.dat</pre>
<h3><span style="color:#ffffff;">.</span></h3>
<h3>Oracle setting</h3>
<p>There is really nothing much to setup. I will use external tables with preprocessor (new 11.2 feature). I wrote about this feature in two older posts, you can find them <a href="http://jiri.wordpress.com/2010/01/19/whats-new-in-oracle-11g-r2-external-tables-preprocessor/" target="_blank">here</a> and <a href="http://jiri.wordpress.com/2010/01/19/no-more-unix-scripts-in-11-2/" target="_blank">here</a></p>
<p>First let me setup oracle directories (login to oracle as DBA or user with grants to create directories)</p>
<pre> CREATE DIRECTORY dir_sample_data as '/home/jiri/Desktop/sample/data';
 CREATE DIRECTORY dir_sample_log  as '/home/jiri/Desktop/sample/log';
 CREATE DIRECTORY dir_sample_bad  as '/home/jiri/Desktop/sample/bad';
 CREATE DIRECTORY dir_sample_exec as '/home/jiri/Desktop/sample/execute';</pre>
<p>then I need to give grants on these directories to a user I will use to run the hadoop (in my case oracle user JIRI)</p>
<pre> GRANT READ        on DIRECTORY dir_sample_data to JIRI;
 GRANT READ, WRITE on DIRECTORY dir_sample_log  to JIRI;
 GRANT READ, WRITE on DIRECTORY dir_sample_bad  to JIRI;
 GRANT EXECUTE     on DIRECTORY dir_sample_exec to JIRI;</pre>
<p>now login as normal oracle user (in my case JIRI) and create external table</p>
<pre>CREATE TABLE JIRI.MYHADOOP_EXT
 (
 SCRIPT_OUTPUT   VARCHAR2(2000)
 )
 ORGANIZATION EXTERNAL
 ( TYPE ORACLE_LOADER
   DEFAULT DIRECTORY dir_sample_data
   ACCESS PARAMETERS
   ( RECORDS DELIMITED BY NEWLINE
     PREPROCESSOR dir_sample_exec:'run_hadoop.sh'
     SKIP 0
     LOGFILE dir_sample_log:'dummy.log'
     BADFILE dir_sample_bad:'dummy.bad'
     NODISCARDFILE
     FIELDS TERMINATED BY '~' OPTIONALLY ENCLOSED BY '~'
     MISSING FIELD VALUES ARE NULL
   )
   LOCATION (dir_sample_data:'dummy.dat')
 )
 REJECT LIMIT 0
 NOPARALLEL
 NOMONITORING;</pre>
<p>That&#8217;s it. Now every time user JIRI runs a query which uses MYHADOOP_EXT table, Oracle will execute unix scripts which executes hadoop script on remote server and returns stdout result back to the oracle user.</p>
<p>As you can see oracle external table preprocessor is very powerful tool, you can use it not only during ETL (as oracle documentation suggests unzip example), but for pretty much any unix level manipulation.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jiri.wordpress.com/939/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jiri.wordpress.com/939/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jiri.wordpress.com/939/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jiri.wordpress.com/939/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jiri.wordpress.com/939/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jiri.wordpress.com/939/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jiri.wordpress.com/939/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jiri.wordpress.com/939/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jiri.wordpress.com/939/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jiri.wordpress.com/939/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jiri.wordpress.com/939/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jiri.wordpress.com/939/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jiri.wordpress.com/939/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jiri.wordpress.com/939/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=939&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jiri.wordpress.com/2010/07/23/oracle-loves-hadoop-integrate-hadoop-seamlessly-into-oracle/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f567ea621740a72d3d6f8de729cb5853?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jiri</media:title>
		</media:content>

		<media:content url="http://jiri.files.wordpress.com/2010/07/screenshot.png?w=300" medium="image">
			<media:title type="html">Screenshot</media:title>
		</media:content>
	</item>
		<item>
		<title>Query CLOB or BLOB from oracle table across DB-LINK with a simple view &#8211; Solution 2</title>
		<link>http://jiri.wordpress.com/2010/06/16/query-clob-or-blob-from-oracle-table-across-db-link-with-a-simple-view-solution-2/</link>
		<comments>http://jiri.wordpress.com/2010/06/16/query-clob-or-blob-from-oracle-table-across-db-link-with-a-simple-view-solution-2/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 19:16:06 +0000</pubDate>
		<dc:creator>jiri</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle DBA]]></category>
		<category><![CDATA[Oracle DML]]></category>
		<category><![CDATA[BLOB]]></category>
		<category><![CDATA[CLOB]]></category>
		<category><![CDATA[DB-LINK]]></category>
		<category><![CDATA[DBLINK]]></category>
		<category><![CDATA[LOB]]></category>
		<category><![CDATA[ORA-22992]]></category>
		<category><![CDATA[ORA22992]]></category>

		<guid isPermaLink="false">http://jiri.wordpress.com/?p=911</guid>
		<description><![CDATA[I will continue my two-part post with second a bit twisted solution. I did not try to optimize this for speed, it&#8217;s a simple proof of concept. This solution requires NO staging tables, but you need tiny bit more grants on remote server (you need to be able to create function, type and a view). [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=911&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I will continue my two-part post with second a bit twisted solution. I did not try to optimize this for speed, it&#8217;s a simple proof of concept. This solution requires NO staging tables, but you need tiny bit more grants on remote server (you need to be able to create function, type and a view).</p>
<p>Please read <a href="http://jiri.wordpress.com/2010/06/04/query-clob-across-db-link-with-in-simple-view/" target="_blank">Solution 1</a> first before you continue with Solution 2 and why you can get error <span style="color:#800000;">ORA-22992:  cannot use LOB locators selected from remote tables</span></p>
<p><span style="color:#ffffff;">.</span></p>
<h3>SOLUTION 2</h3>
<p>This is a bit twisted solution, but works. Basically you first need to convert LOB (in these example I refer to CLOB, BLOB is similar but you will probably not use varchar2) to multiple varchar2(4000) on remote server &#8211; for example CLOB with size 8100 will be converted to 3 varchar2(4000), then read this data across db-links, then combine it back to CLOB on a local server. This can be all done on a fly without any staging tables.</p>
<p><span style="color:#ffffff;">.</span></p>
<h4>1. REMOTE SERVER</h4>
<p>let&#8217;s first define one table on remote server and load it with some  data.</p>
<pre>create table RemotetTableWithClob (myid number, myclob clob);

insert into RemotetTableWithClob (myid, myclob) values (1, 'This is small test');
insert into RemotetTableWithClob (myid, myclob) values (2, 'Another Test');
insert into RemotetTableWithClob (myid, myclob) values (3, 'One more test');
commit;</pre>
<p>then we need to create a function for converting CLOB to multiple varchar2 and hide it behind view. Please note I tried to use collection here, but you cannot query collection across db-link, you will be facing error <span style="color:#800000;">ORA-22804: remote operations not permitted on object tables or user-defined type columns </span>thus I convert the clob to basically multi-row view (number of records is variable and depends on size of LOB). This is very simple</p>
<pre>CREATE TYPE object_row_type AS OBJECT (
 MYORDER            NUMBER,
 MYID               NUMBER,
 MYCLOB_AS_VARCHAR  VARCHAR2(4000)    );

CREATE TYPE object_table_type AS TABLE OF object_row_type;

-- convert CLOB to multi-row varchar2
CREATE OR REPLACE FUNCTION CONVERT_CLOB_TO_VARCHAR RETURN object_table_type PIPELINED IS
PRAGMA AUTONOMOUS_TRANSACTION;

v_clob_length  number;
v_loops        number;
v_varchar_size number := 4000;

BEGIN

 FOR cur IN (SELECT myid, myclob from RemoteTableWithClob)
 LOOP
   v_clob_length := dbms_lob.getlength (cur.MyClob);
   v_loops := trunc(v_clob_length/v_varchar_size) + sign (mod(v_clob_length,v_varchar_size ) ) - 1;

   FOR i IN 0..v_loops
   LOOP
     PIPE ROW(object_row_type(i + 1, cur.myid, dbms_lob.substr( cur.MyClob, v_varchar_size, v_varchar_size * i + 1 )));
   END LOOP;

 END LOOP;
 COMMIT;
 RETURN;
END;
</pre>
<p>now the view on remote server</p>
<pre>
-- create view to show the clob converted to varchar
-- please notice there is important column MYORDER (order of individual varchar chunks)
CREATE VIEW myRemoteData as
SELECT * FROM TABLE(CONVERT_CLOB_TO_VARCHAR) a;</pre>
<p><span style="color:#ffffff;">gg.</span></p>
<h4>2. LOCAL SERVER</h4>
<p>on a local server, I read the records and convert them to collection (this can be done in a query using CAST-MULTISET), then I use a function to convert this collection back to CLOB.</p>
<p><span style="color:#ffffff;">.</span></p>
<pre>CREATE PUBLIC DATABASE LINK RemoteServer  USING 'remoteserver';
CREATE OR REPLACE TYPE myTableType  as table of varchar2(4000);

CREATE OR REPLACE FUNCTION JIRI.F_VARCHAR_TO_CLOB (input_table_of_varchar myTableType) RETURN CLOB IS
PRAGMA AUTONOMOUS_TRANSACTION;
v_clob  clob;
BEGIN
FOR i IN 1..input_table_of_varchar.COUNT
LOOP
 -- the concatenation below could be probably done using DBMS_LOB.WRITEAPPEND <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />
 v_clob := v_clob || input_table_of_varchar(i);
END LOOP;
RETURN v_clob;
END;
</pre>
<p>and here is the final view on local server</p>
<pre>
-- the view first converts separate varchar2 records to a collection
-- then function is used to convert the collection to CLOB
CREATE OR REPLACE VIEW myRemoteData as
SELECT a.myid,
       F_VARCHAR_TO_CLOB( CAST(MULTISET(SELECT b.MYCLOB_AS_VARCHAR
                                          FROM myRemoteData@remoteserver b
                                         WHERE a.MYID = b.MYID
                                      ORDER BY MYORDER   ) as myTableType)
                        ) myClob
FROM REMOTETABLEWITHCLOB@remoteserver a;</pre>
<p>As you can see the process is very simple. I tested it with CLOB with more than 100,000 characters on my tiny VMWARE instance and got pretty decent timing. Please take the code above as a proof of concept, not as a tuned production ready solution.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jiri.wordpress.com/911/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jiri.wordpress.com/911/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jiri.wordpress.com/911/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jiri.wordpress.com/911/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jiri.wordpress.com/911/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jiri.wordpress.com/911/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jiri.wordpress.com/911/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jiri.wordpress.com/911/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jiri.wordpress.com/911/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jiri.wordpress.com/911/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jiri.wordpress.com/911/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jiri.wordpress.com/911/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jiri.wordpress.com/911/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jiri.wordpress.com/911/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=911&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jiri.wordpress.com/2010/06/16/query-clob-or-blob-from-oracle-table-across-db-link-with-a-simple-view-solution-2/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f567ea621740a72d3d6f8de729cb5853?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jiri</media:title>
		</media:content>
	</item>
		<item>
		<title>Query CLOB or BLOB from oracle table across DB-LINK with a simple view &#8211; Solution 1</title>
		<link>http://jiri.wordpress.com/2010/06/04/query-clob-across-db-link-with-in-simple-view/</link>
		<comments>http://jiri.wordpress.com/2010/06/04/query-clob-across-db-link-with-in-simple-view/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 21:17:15 +0000</pubDate>
		<dc:creator>jiri</dc:creator>
				<category><![CDATA[Oracle DBA]]></category>
		<category><![CDATA[Oracle DML]]></category>
		<category><![CDATA[BLOB]]></category>
		<category><![CDATA[CLOB]]></category>
		<category><![CDATA[DB-LINK]]></category>
		<category><![CDATA[DBLINK]]></category>
		<category><![CDATA[LOB]]></category>
		<category><![CDATA[ORA-22992]]></category>
		<category><![CDATA[ORA22992]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://jiri.wordpress.com/?p=798</guid>
		<description><![CDATA[This is not so unusual scenario: You have a table with one or more LOB fields on remote oracle server and you want to query that table across db-link. If you try simple SELECT statement you will be facing ORA-22992: cannot use LOB locators selected from remote tables oooops, what next. There are several workarounds, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=798&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is not so unusual scenario: You have a table with one or more LOB fields on remote oracle server and you want to query that table across db-link. If you try simple SELECT statement you will be facing <span style="color:#800000;">ORA-22992: cannot use LOB locators selected from remote tables</span></p>
<p>oooops, what next. There are several workarounds, let me try to tackle one easy solution.</p>
<address>This testing was done using oracle 10g running on remote windows machine and 11.2 running on local redhat5 server, but it should in general work for any 10g/11g servers.</address>
<address><span style="color:#ffffff;">.</span><br />
</address>
<address> </address>
<address>for the second solution follow this <a href="http://jiri.wordpress.com/2010/06/16/query-clob-or-blob-from-oracle-table-across-db-link-with-a-simple-view-solution-2/">link</a><br />
</address>
<address><span style="color:#ffffff;">.</span></address>
<address> </address>
<h3><span style="color:#ffffff;">.</span></h3>
<h3>SOLUTION 1</h3>
<p>The first solution is actually very simple. Create a table (I prefer temporary table) on local oracle server, insert data from remote server to local server using INSERT INTO and then query local server. This can be all fully automated and hidden from users &#8230;</p>
<h4>1. REMOTE SERVER</h4>
<p>let&#8217;s first define one table on remote server and load it with some data, that&#8217;s all we need to do on remote server.</p>
<pre>create table RemotetTableWithClob (myid number, myclob clob);

insert into RemotetTableWithClob (myid, myclob) values (1, 'This is small test');
insert into RemotetTableWithClob (myid, myclob) values (2, 'Another Test');
insert into RemotetTableWithClob (myid, myclob) values (3, 'One more test');
commit;</pre>
<h3><span style="color:#ffffff;">.</span></h3>
<h4>2. LOCAL SERVER</h4>
<p>first, let me create db-link (I have same userID on both servers, this will be passwordless db-link) and then try to run simple query</p>
<pre>CREATE PUBLIC DATABASE LINK RemoteServer  USING 'remoteserver';

select myid, substr(myclob, 1, 5) mytext from remotetablewithclob@RemoteServer;
<span style="color:#800000;">ORA-22992: cannot use LOB locators selected from remote tables</span></pre>
<p>as you can see I cannot query the CLOB field.</p>
<h3><span style="color:#ffffff;">.</span></h3>
<h4>3. SIMPLE WORKAROUND</h4>
<p>The simply workaround is to bring the data from remote server to local server and then query local table. I use temporary tables simply because I don&#8217;t want to worry about deleting the data and concurrent users.</p>
<pre>create global temporary table LocalTempTableWithClob
 (myid number,  myclob clob) ON COMMIT PRESERVE ROWS;

insert into  LocalTempTableWithClob Select * from RemoteTableWithClob@RemoteServer;
select  myid, substr(myclob, 1, 5) mytext from LocalTempTableWithClob;

MYID   MYTEXT
--------------
 1  This
 2  Anoth
 3  One m</pre>
<h3><span style="color:#ffffff;">.</span></h3>
<h4>4. NOW THE REAL TRICK</h4>
<p>As you can see (3) works pretty good and it can be the end of the post, but &#8230; what if you have multiple users who want to query the data. Are you going to ask them to run the insert every time the want to query the table?</p>
<p>Here is my solution to that problem. I basically use a function to insert data from remote to local table and then display the result of local table instead. This is all done in a single pass in a single function and can be hidden from users via view.</p>
<p>I use pipelined function because I really love them and hope more users are going to start using them.</p>
<pre>CREATE TYPE object_row_type AS OBJECT (
 MYID               NUMBER,
 MYCLOB             CLOB             );

CREATE TYPE object_table_type AS TABLE OF object_row_type;

CREATE OR REPLACE FUNCTION GETCLOB RETURN object_table_type PIPELINED IS
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
 insert into LocalTempTableWithClob Select * from RemoteTableWithClob@RemoteServer;
 commit;
 FOR cur IN (SELECT myid, myclob from LocalTempTableWithClob)
 LOOP
   PIPE ROW(object_row_type(cur.myid, cur.myclob));
 END LOOP;
 DELETE FROM LocalTempTableWithClob;
 COMMIT;
 RETURN;
END;

create view myRemoteData as
SELECT * FROM TABLE(GetClob) a;

select myid, substr(myclob, 1, 5) mytext from myRemoteData;

MYID  MYTEXT
--------------
 1  This
 2  Anoth
 3  One m</pre>
<p>As you can see the solution is very simple, the function is hidden behind the view and users do not even know about the data insert.</p>
<p>Please note this is a bit oversimplified scenario, you can easily extend the function to add custom WHERE clause (which I would highly recommend, you don&#8217;t want to move whole table over dblink every single time), you can even make the function very universal for any querying of LOB across db-link.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jiri.wordpress.com/798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jiri.wordpress.com/798/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jiri.wordpress.com/798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jiri.wordpress.com/798/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jiri.wordpress.com/798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jiri.wordpress.com/798/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jiri.wordpress.com/798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jiri.wordpress.com/798/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jiri.wordpress.com/798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jiri.wordpress.com/798/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jiri.wordpress.com/798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jiri.wordpress.com/798/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jiri.wordpress.com/798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jiri.wordpress.com/798/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=798&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jiri.wordpress.com/2010/06/04/query-clob-across-db-link-with-in-simple-view/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f567ea621740a72d3d6f8de729cb5853?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jiri</media:title>
		</media:content>
	</item>
		<item>
		<title>Oracle External Tables by Examples part 5 – missing features</title>
		<link>http://jiri.wordpress.com/2010/04/16/oracle-external-tables-by-examples-part-5-%e2%80%93-missing-features/</link>
		<comments>http://jiri.wordpress.com/2010/04/16/oracle-external-tables-by-examples-part-5-%e2%80%93-missing-features/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 22:12:09 +0000</pubDate>
		<dc:creator>jiri</dc:creator>
				<category><![CDATA[Oracle External Tables]]></category>
		<category><![CDATA[external tables]]></category>
		<category><![CDATA[load tail]]></category>
		<category><![CDATA[missing features]]></category>
		<category><![CDATA[SKIP]]></category>

		<guid isPermaLink="false">http://jiri.wordpress.com/?p=783</guid>
		<description><![CDATA[This is maybe a bit unusual post, I almost never post about missing feature and rather focus what does exist. Although I love Oracle External tables, I must admit there are few missing features which can be easily implemented and would save a lot of time in some instances. Please note most of the missing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=783&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is maybe a bit unusual post, I almost never post about missing feature and rather focus what does exist. Although I love Oracle External tables, I must admit there are few missing features which can be easily implemented and would save a lot of time in some instances.</p>
<p>Please note most of the missing features below can be partially or fully patched by workarounds, I&#8217;ve done it million times before. The point I am trying to make is to have these implemented directly without any workarounds.</p>
<p><span style="color:#ffffff;">.</span></p>
<h4>1. LOAD FIRST x</h4>
<p>This is very simple, I would love to be able to specify to load first x for example first 2 records. This would be great in cases where you want to load for example header only.</p>
<p>Is there a workaround? Sure there is, but it&#8217;s a workaround and not a true solution</p>
<p>a. if you are lucky and the header has specific characteristic you can use filter LOAD WHEN</p>
<p>b. you can use REJECT LIMIT UNLIMITED &#8211; this is possible but I really do not like it, simply because you by definition expect bad records. What if the header is 5 rows and row 3 has an issue and is rejected?</p>
<p>c. SELECT * FROM EXTERNAL_TABLE WHERE ROWNUM &lt; X</p>
<p>This is certainly possible, but SQL engine runs after the external table load (this is defined by readsize cache) and although this is somewhat working, you might still get rejects because Oracle might read 7 records instead of just 1.</p>
<p>d. use unix and separate header and body &#8211; this is clean solution but is extra step</p>
<h3><span style="color:#ffffff;">.</span></h3>
<h4>2. LOAD LAST X</h4>
<p>This is very similar to LOAD FIRST, this has however bigger implication. Just imagine you have 40GB file, if you use for example LOAD WHEN you will be waiting for a long time to get the trailing record. Unix file split is probably the most effective workaround here.</p>
<h3><span style="color:#ffffff;">.</span></h3>
<h4>3. SKIP LAST X</h4>
<p>External table supports SKIP X meaning skip first x records. This is great for skipping header during the load. I would love to see similar feature for skipping last X records (skipping loading trailing record). Again, there are possible workarounds, but why do we need them if it could to implement this directly to external tables?</p>
<p>Please share your ideas what could be added to external tables load.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jiri.wordpress.com/783/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jiri.wordpress.com/783/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jiri.wordpress.com/783/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jiri.wordpress.com/783/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jiri.wordpress.com/783/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jiri.wordpress.com/783/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jiri.wordpress.com/783/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jiri.wordpress.com/783/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jiri.wordpress.com/783/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jiri.wordpress.com/783/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jiri.wordpress.com/783/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jiri.wordpress.com/783/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jiri.wordpress.com/783/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jiri.wordpress.com/783/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=783&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jiri.wordpress.com/2010/04/16/oracle-external-tables-by-examples-part-5-%e2%80%93-missing-features/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f567ea621740a72d3d6f8de729cb5853?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jiri</media:title>
		</media:content>
	</item>
		<item>
		<title>Oracle External Tables by Examples part 4 &#8211; column_transforms Clause (load CLOB BLOB or any constant using external tables)</title>
		<link>http://jiri.wordpress.com/2010/03/29/oracle-external-tables-by-examples-part-4-column_transforms-clause-load-clob-blob-or-any-constant-using-external-tables/</link>
		<comments>http://jiri.wordpress.com/2010/03/29/oracle-external-tables-by-examples-part-4-column_transforms-clause-load-clob-blob-or-any-constant-using-external-tables/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 20:38:08 +0000</pubDate>
		<dc:creator>jiri</dc:creator>
				<category><![CDATA[Oracle External Tables]]></category>
		<category><![CDATA[10g]]></category>
		<category><![CDATA[11g]]></category>
		<category><![CDATA[BLOB]]></category>
		<category><![CDATA[CLOB]]></category>
		<category><![CDATA[column transforms]]></category>
		<category><![CDATA[column_transforms]]></category>
		<category><![CDATA[external table]]></category>
		<category><![CDATA[LOB]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://jiri.wordpress.com/?p=763</guid>
		<description><![CDATA[Starting Oracle 10g you can load any CLOB/BLOB (any file including text, xml, jpeg, doc, pdf, &#8230;. whatever format you like) which resides in separate file(s) to Oracle using external tables and no longer need SQL*Plus (unless you plan to load data over network). It is done using very interesting column_transforms clause. let&#8217;s assume you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=763&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Starting Oracle 10g you can load any CLOB/BLOB (any file including text, xml, jpeg, doc, pdf, &#8230;. whatever format you like) which resides in separate file(s) to Oracle using external tables and no longer need SQL*Plus (unless you plan to load data over network). It is done using very interesting column_transforms clause.</p>
<p>let&#8217;s assume you have customer.dat file which looks like this</p>
<pre>CUSTOMER_ID,CUSTOMER_ACQUIRE_DT, CUSTOMER_FILE_NM
123456,12/23/2001,jiri_smith.txt
234567,01/17/1999,scott_walker.txt
345678,05/16/2009,jim_brown.txt</pre>
<p>the file includes next to customer_id also a date when was the customer acquired and also a file name which includes more detail information. In my example above it means that I have next to customer.dat file also jiri_smith.txt file, scott_walker.txt and jim_brown.txt file.</p>
<p>Here is the goal:</p>
<p>1. use external tables to load customer.dat file as well as all txt files<br />
2. load txt files into CLOB field (you can load it to BLOB using the same technique)<br />
3. present date as true date (correctly parse mask<br />
4. add additional static column which defines what vendor sent the file<br />
5. add windows drive name http://myserver/ to customer_file_nm so users know where the text file reside (this is kinda silly requirement since we load it to CLOB, but still &#8230;).</p>
<p>First let&#8217;s define directories, this is very straightforward. Notice I define separate directory for customer.dat and individual txt files (this can of course be one directory).</p>
<pre>CREATE OR REPLACE DIRECTORY "DIR_USERS_JIRI_DATA" AS '/work/users/jiri/data';
CREATE OR REPLACE DIRECTORY "DIR_USERS_JIRI_FILES" AS '/work/users/jiri/files';
CREATE OR REPLACE DIRECTORY "DIR_USERS_JIRI_LOG" AS '/work/users/jiri/log';
CREATE OR REPLACE DIRECTORY "DIR_USERS_JIRI_BAD" AS '/work/users/jiri/bad';

GRANT READ, WRITE ON DIRECTORY DIR_USERS_JIRI_DATA TO JIRI;
GRANT READ, WRITE ON DIRECTORY DIR_USERS_JIRI_FILES TO JIRI;
GRANT READ ON DIRECTORY DIR_USERS_JIRI_LOG TO JIRI;
GRANT READ ON DIRECTORY DIR_USERS_JIRI_BAD TO JIRI;</pre>
<p>The next step is to define external table (yes, all steps 1-5 can be done using one single DDL)</p>
<pre>CREATE TABLE customer_ext
(
 CUSTOMER_ID         number,
 CUSTOMER_ACQUIRE_DT date,
 SERVICER_NM         varchar2(60),
 FILE_NM             varchar2(120),
 CUSTOMER_PROFILE    clob
)
organization external
(
 type oracle_loader
 default directory dir_sample_data
 access parameters
 (
 records delimited by NEWLINE
 skip 1
 logfile dir_sample_log:'customer.log'
 badfile dir_sample_bad:'customer.bad'
 nodiscardfile
 fields terminated by ','
 missing field values are null
 (
 CUSTOMER_ID          CHAR(10),
 CUSTOMER_ACQUIRE_DT  CHAR(11)<strong> DATE_FORMAT DATE MASK "MM/DD/YYYY",</strong>
 CUSTOMER_FILE_NM     CHAR(60)
 )
<strong> column transforms
  (
   SERVICER_NM      FROM CONSTANT 'Web Data Delivery Inc.',
   FILE_NM          FROM CONCAT  (CONSTANT 'http://myserver/', CUSTOMER_FILE_NM),
   CUSTOMER_PROFILE FROM LOBFILE (CUSTOMER_FILE_NM) FROM (dir_sample_files)
  )
 )</strong>
 location (dir_sample_data:'customer.dat')
)
reject limit 0
noparallel
nomonitoring;</pre>
<p>it cannot be easier than that</p>
<pre>SELECT CUSTOMER_ID,
       to_char(CUSTOMER_ACQUIRE_DT, 'YYYYMMDD') ACQUIRE_DT,
       SERVICER_NM,
       FILE_NM,
       SUBSTR(CUSTOMER_PROFILE, 1, 10) CUSTOMER_PROFILE,
       DBMS_LOB.getlength(CUSTOMER_PROFILE) CLOB_LENGTH
  FROM CUSTOMER_EXT;

CUSTOMER_ID ACQUIRE_DT SERVICER_NM            FILE_NM                           CUSTOMER_PROFILE CLOB_LENGTH
----------------------------------------------------------------------------------------------------
123456     20011223    Web Data Delivery Inc. http://myserver/jiri_smith.txt    dfdfdfdfdf       55
234567     19990117    Web Data Delivery Inc. http://myserver/scott_walker.txt  rrrererere       564
345678     20090516    Web Data Delivery Inc. http://myserver/jim_brown.txt     gretgertgr       444
----------------------------------------------------------------------------------------------------
</pre>
<p>as you can see, we can do all requirements in one simple external table DDL.</p>
<p>1. we used external table<br />
2. we load LOB using COLUMN_TRANSFORMS LOBFILE clause<br />
3. we set the correct mask for date using DATE MASK<br />
4. we created new SERVICER_NM static column (virtual column) wih static description using COLUMN TRANSFORMS CONSTANT<br />
5.we appended constant to existing field (merged field with static value) using COLUMN TRANSFORMS CONCAT</p>
<p>please note COLUMN TRANSFORMS cannot be used for any other transformation -  CONSTANT, CONCAT and LOBFILE are the only options. I wish there would be more options and chance to add custom functions, but there is currently no such option.</p>
<p>You can find complete documentation <a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e10701/et_params.htm#insertedID4" target="_blank">here</a> (there are however no real examples on how to use column transforms clause)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jiri.wordpress.com/763/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jiri.wordpress.com/763/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jiri.wordpress.com/763/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jiri.wordpress.com/763/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jiri.wordpress.com/763/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jiri.wordpress.com/763/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jiri.wordpress.com/763/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jiri.wordpress.com/763/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jiri.wordpress.com/763/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jiri.wordpress.com/763/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jiri.wordpress.com/763/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jiri.wordpress.com/763/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jiri.wordpress.com/763/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jiri.wordpress.com/763/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=763&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jiri.wordpress.com/2010/03/29/oracle-external-tables-by-examples-part-4-column_transforms-clause-load-clob-blob-or-any-constant-using-external-tables/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f567ea621740a72d3d6f8de729cb5853?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jiri</media:title>
		</media:content>
	</item>
		<item>
		<title>send emails using UTL_MAIL Oracle package and Google GMAIL SMTP Server</title>
		<link>http://jiri.wordpress.com/2010/03/24/send-emails-using-utl_mail-and-google-gmail-smtp-server/</link>
		<comments>http://jiri.wordpress.com/2010/03/24/send-emails-using-utl_mail-and-google-gmail-smtp-server/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 16:12:58 +0000</pubDate>
		<dc:creator>jiri</dc:creator>
				<category><![CDATA[Oracle DBA]]></category>

		<guid isPermaLink="false">http://jiri.wordpress.com/?p=745</guid>
		<description><![CDATA[This setting is probably not what you going to use in your organization, I use this in my home. My guess is the usage in your case would be somewhat similar. As you probably know in Oracle Database 10g and above you can send email using UTL_MAIL (10.1 had tons of bugs, I would not [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=745&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This setting is probably not what you going to use in your organization, I use this in my home. My guess is the usage in your case would be somewhat similar.</p>
<p>As you probably know in Oracle Database 10g and above you can send email using UTL_MAIL (10.1 had tons of bugs, I would not recommend UTL_MAIL prior 10.2). Older releases of Oracle can use UTL_SMTP &#8211; I still use it if I want to attach large files, you can also use custom JAVA stored procedure.</p>
<p>Let me focus on UTL_MAIL here&#8230;. it&#8217;s really easy to use. This package is not installed by default. First you need to install it (see <a href="http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_mail.htm" target="_blank">oracle documentation</a> for detail how-to), the only parameter you will need to set is SMTP_OUT_SERVER which is basically SMTP host name and port (usually 25).</p>
<p>Simple huh? Well yes if you have internal SMTP server and that server does not require authentication. If you are like me then you probably don&#8217;t run SMTP server and would prefer to use Google GMAIL SMTP server. So is there a way to use UTL_MAIL with GMAIL SMTP?</p>
<p>Simple answer is NO, but there is simple workaround.</p>
<p>What you have to do is to run SMTP Relay, which is basically tiny app which routes any SMTP traffic to other SMTP server. As you probably guess this SMTP relay is going to run on your internal server, it will accept any SMTP traffic (including traffic from your Oracle server) with no password restrictions and then authenticate and relay this traffic to GMAIL SMTP Server.</p>
<p>There are quite of lot of SMTP Relay servers, I personally really like free <a href="http://emailrelay.sourceforge.net/" target="_blank">E-MailRelay</a> because it runs on Linux, Unix and Windows and source code is freely available.</p>
<p>note: I&#8217;m going to run E-MailRelay on the same server where Oracle resides (Oracle 10.2 on RedHat 5 in VMWARE). Since this is home setting, it should be OK. I also tested in on Windows 2003 with Oracle XE running in VMWARE.</p>
<p><strong>1. download </strong>E-MailRelay for your system and extract it from the archive</p>
<p><strong>2. install it</strong></p>
<p>here is how to install it for <a href="http://emailrelay.sourceforge.net/windows.html#H_1" target="_blank">Windows<br />
</a>The install program basically puts all files in one folder, creates script (BAT file) as well as emailrelay.auth file. The easies way is to replace emailrelay.auth file with (3) and edit BAT file and replace the content with (4) &#8211; just make sure the paths are correct.</p>
<p>on linux look at file called &#8220;install&#8221; &#8211; it has very detail easy to follow instructions (basically run configure, then make, then make install)</p>
<p><strong>3. create secret file</strong> (this is simple file which includes your gmail UID/PSW &#8211; assuming you already have your gmail email setup), I call it emailrelay.auth and save it to folder /etc</p>
<pre>login client myname@gmail.com mypassword</pre>
<p><strong>4. run emailrelay</strong></p>
<pre>emailrelay --as-proxy smtp.gmail.com:587 --client-tls --client-auth /etc/emailrelay.auth</pre>
<p><strong>5. install and configure UTL_MAIL</strong></p>
<p>open SQL plus, login as sys and execute 3 statements below, change ip-address:port to your IP address, keep port on 25, if you run it on the same server where oracle sits, you can use localhost instead of IP address.</p>
<pre>@$ORACLE_HOME/rdbms/admin/utlmail.sql;
@$ORACLE_HOME/rdbms/admin/prvtmail.plb;
alter system set smtp_out_server = 'ip-address:port' scope=Both;</pre>
<p><strong>6. send</strong> you first email</p>
<pre>UTL_MAIL.send(sender     =&gt; 'My Name "&lt;myname@gmail.com&gt;"',
              recipients =&gt; 'myname@gmail.com',
              subject    =&gt; 'Test',
              message    =&gt; 'It works!');</pre>
<p>Please make sure sender is exactly same format as above (keep the double-quotes around the email address), otherwise you will get error <span style="color:#800000;">SMTP permanent error: 553 mailbox name not allowed: missing or invalid angle brackets in mailbox name</span></p>
<p>It cannot be easier than that. Small note: if your organization requires SMTP authentication and you cannot use SMTP Relay trick, then you can use UTL_SMTP for your email communication (UTL_SMTP does support authentication).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jiri.wordpress.com/745/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jiri.wordpress.com/745/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jiri.wordpress.com/745/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jiri.wordpress.com/745/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jiri.wordpress.com/745/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jiri.wordpress.com/745/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jiri.wordpress.com/745/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jiri.wordpress.com/745/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jiri.wordpress.com/745/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jiri.wordpress.com/745/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jiri.wordpress.com/745/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jiri.wordpress.com/745/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jiri.wordpress.com/745/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jiri.wordpress.com/745/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=745&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jiri.wordpress.com/2010/03/24/send-emails-using-utl_mail-and-google-gmail-smtp-server/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f567ea621740a72d3d6f8de729cb5853?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jiri</media:title>
		</media:content>
	</item>
		<item>
		<title>Informatica Powercenter up and running in less than 30 minutes and yes it’s free (well free trial at least, with full PDF documentation)!</title>
		<link>http://jiri.wordpress.com/2010/03/17/informatica-powercenter-up-and-running-in-less-than-30-minutes-and-yes-its-free/</link>
		<comments>http://jiri.wordpress.com/2010/03/17/informatica-powercenter-up-and-running-in-less-than-30-minutes-and-yes-its-free/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 20:21:47 +0000</pubDate>
		<dc:creator>jiri</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://jiri.wordpress.com/?p=719</guid>
		<description><![CDATA[This is very simple and quick tip for everybody who wants to have Informatica Powercenter up and running in very short period of time and does not want to spend a dime. Yes all components are free and you are not breaking and license. Take this as a very quick demo. what you need 1. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=719&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is very simple and quick tip for everybody who wants to have Informatica Powercenter up and running in very short period of time and does not want to spend a dime. Yes all components are free and you are not breaking and license.</p>
<p>Take this as a very quick demo.</p>
<p><a href="http://jiri.files.wordpress.com/2010/03/62169701_5c4daa0d1f1.jpg"><img class="size-full wp-image-975 alignnone" title="62169701_5c4daa0d1f" src="http://jiri.files.wordpress.com/2010/03/62169701_5c4daa0d1f1.jpg?w=580" alt=""   /></a></p>
<h2>what you need</h2>
<p>1. VMWare Player<br />
2. MS Windows Server<br />
3. Oracle Database<br />
4. Informatica Server and Client</p>
<h2>Here we go &#8230;</h2>
<p>First, let&#8217;s start with VMWare. There are some other free options, I really like WMVare Player. It&#8217;s quick to install, very easy to use and Unity mode blows every other option away. You can get free VMWare Player <a href="http://www.vmware.com/products/player/" target="_blank">here</a></p>
<p>After you install it, the second step is to download free 30 day evaluation of <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=77f24c9d-b4b8-4f73-99e3-c66f80e415b6&amp;DisplayLang=en" target="_blank">Windows 2003 server</a>. After you download it, you can easily open it (click OPEN, not NEW instance and open WIN2K3R2EESP2.vmc) using VMWare Player &#8211; please note VMWare Player converts it to it&#8217;s own format (this conversion took around 30 seconds on my PC).</p>
<p>Now start VMWare with Windows Server 2003 (make sure you enable networking, it&#8217;s by default turned off in VMWare machine). After you login to the server using Administrator/Evaluation1 , download Oracle Database (download it from Windows 2003 server you just installed). The easiest way is to start with Oracle XE &#8211; it&#8217;s super easy to install it and you really don&#8217;t need to know much about oracle. You can get it <a href="http://www.oracle.com/technology/software/products/database/xe/htdocs/102xewinsoft.html" target="_blank">here</a>. The installation is painless, the only thing you need to set next to destination directory is password for sys.</p>
<p>After you install it, open web console and either create new user or enable SCOTT user &#8211; this user will be used by informatica repository and you need this ID during informatica installation. XE comes with easy to use web interface, it should take couple seconds to create new userid. You can of course use sql*plus</p>
<p>The last component is Informatica Powercenter. I&#8217;m not sure if Informatica offers demo version, but Oracle does. Wait, you said Oracle? That&#8217;s right. Back in the old days when Hyperion was standalone company they offered Informatica Powercenter as part of their Essbase server offer, they called it Hyperion Data Integration Management sometimes called as DIM. I&#8217;m a bit surprised Oracle still offer it. From what I can tell it&#8217;s really full blown Informatica Powercenter 8.1 with few cut-down features &#8211; you cannot run in parallel and you cannot use some of the drivers which come with Powercenter offered through Informatica. Download your copy <a href="http://www.oracle.com/technetwork/middleware/bi-foundation/downloads/hyperion-data-integration-111110-094715.html" target="_blank">here </a></p>
<p>The installation is very straightforward, when the setup asks for database location &#8211; select</p>
<p>database: ORACLE<br />
host name:  localhost<br />
SID: XE<br />
USERID/PASWORD: whatever you created after you installed Oracle Database</p>
<p>grab your license key here <a rel="nofollow" href="http://licensecodes.oracle.com/hyperion.html">http://licensecodes.oracle.com/hyperion.html</a></p>
<p>That&#8217;s pretty much it. The downloads of the software components can take some time (windows and informatica are pretty big), the actual installation is very quick and does not require more than couple reboots (one for VMWare, one for Windows 2003).</p>
<p>small note: it can happen that when you reboot Windows2003 server, Informatica services are not going to start. This is possible that it tries to start before OracleXE starts. The easiest way is to wait for all services to start, then restart OracleXE services and then start Informatica services (both have shortcut in START-PROGRAMS menu).</p>
<p>One additional note about Window vs Linux vs Solaris &#8230; Yes I prefer Oracle on Linux or Solaris, but let&#8217;s be honest, if you are doing it for the first time, you are going to spend quite a lot of time making sure all prerequirements are met. Installing XE on Windows is very quick and requires virtually no special setting.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jiri.wordpress.com/719/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jiri.wordpress.com/719/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jiri.wordpress.com/719/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jiri.wordpress.com/719/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jiri.wordpress.com/719/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jiri.wordpress.com/719/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jiri.wordpress.com/719/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jiri.wordpress.com/719/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jiri.wordpress.com/719/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jiri.wordpress.com/719/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jiri.wordpress.com/719/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jiri.wordpress.com/719/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jiri.wordpress.com/719/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jiri.wordpress.com/719/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=719&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jiri.wordpress.com/2010/03/17/informatica-powercenter-up-and-running-in-less-than-30-minutes-and-yes-its-free/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f567ea621740a72d3d6f8de729cb5853?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jiri</media:title>
		</media:content>

		<media:content url="http://jiri.files.wordpress.com/2010/03/62169701_5c4daa0d1f1.jpg" medium="image">
			<media:title type="html">62169701_5c4daa0d1f</media:title>
		</media:content>
	</item>
		<item>
		<title>what’s new in Oracle 11g R2 – DEFERRED SEGMENT CREATION</title>
		<link>http://jiri.wordpress.com/2010/02/25/what%e2%80%99s-new-in-oracle-11g-r2-%e2%80%93-deferred-segment-creation/</link>
		<comments>http://jiri.wordpress.com/2010/02/25/what%e2%80%99s-new-in-oracle-11g-r2-%e2%80%93-deferred-segment-creation/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 23:29:33 +0000</pubDate>
		<dc:creator>jiri</dc:creator>
				<category><![CDATA[Oracle DBA]]></category>

		<guid isPermaLink="false">http://jiri.wordpress.com/?p=678</guid>
		<description><![CDATA[This is really small but very useful feature. It was published in ASK TOM (please read it, it&#8217;s very interesting as most of Tom&#8217;s posts), Tom did not mention the exclusions, so if you follow his samples and create tables in SYSTEM schema or add partitions, you can be surprised either with the fact that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=678&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is really small but very useful feature. It was published in ASK TOM (please read it, it&#8217;s very interesting as most of Tom&#8217;s posts), Tom did not mention the exclusions, so if you follow his samples and create tables in SYSTEM schema or add partitions, you can be surprised either with the fact that the initial segment was created or if you try to force in on table DDL level with error ORA-14223: Deferred segment creation is not supported for this table</p>
<p>If you create a table (until oracle 11.2 R2), Oracle database allocates space for initial segment. This might be very small segment (if you want), it can be large segment if you expect a lot of data, this new feature allows you to defer creation of this initial segment until you load some data to the table and thus you can save some space in case you have a lot of tables (and maybe never plan to populate them &#8211; in case of large SAP installation for example). There is very small timing penalty if you create the initial segment when you load the data vs create the segment in advance (this is usually very tiny and I personally don&#8217;t see any big risk here).</p>
<p>There is of course &#8220;small&#8221; but &#8230; This feature can be applied to almost all tables (all except partitioned tables, index-organized tables, clustered tables, global temporary tables, session-specific temporary tables, internal tables, typed tables, AQ tables, external tables) , lobs and almost all indexes (all except partitioned indexes, bitmap join indexes, and domain indexes). The tables also cannot be created in SYS, SYSTEM, PUBLIC, OUTLN, or XDB schemas (this is probably not a big deal in your case). Also please note you have to have compatibility set to &#8217;11.2.0&#8242; .</p>
<p>Small exclusions huh?</p>
<p>One interesting by-product is this is that since you don&#8217;t pre-allocate any extents, you do not need quota on the tablespace you create the table in.</p>
<p>in Oracle 11.2 R2 it can be a bit space-saving exercise and is actually very easy. You can alter session or system or set it on table DDL level, the default is TRUE.</p>
<pre>alter session set deferred_segment_creation=true;</pre>
<p>or you can set it on system wide level</p>
<pre>alter system set deferred_segment_creation=true;</pre>
<p>and then create table as usual or set this on table level only using</p>
<pre>CREATE TABLE .... SEGMENT CREATION IMMEDIATE</pre>
<p>or</p>
<pre>CREATE TABLE ... SEGMENT CREATION DEFERRED</pre>
<p>1. If you query user_extents view before you insert any data, you can see that there are no rows = no extents (nothing is pre-allocated).</p>
<p>2. if you query dba_tables view, you can see that there is new column called SEGMENT_CREATED which indicates whether the initial segment was created or not YES/NO</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jiri.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jiri.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jiri.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jiri.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jiri.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jiri.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jiri.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jiri.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jiri.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jiri.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jiri.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jiri.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jiri.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jiri.wordpress.com/678/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jiri.wordpress.com&amp;blog=46344&amp;post=678&amp;subd=jiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jiri.wordpress.com/2010/02/25/what%e2%80%99s-new-in-oracle-11g-r2-%e2%80%93-deferred-segment-creation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f567ea621740a72d3d6f8de729cb5853?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jiri</media:title>
		</media:content>
	</item>
	</channel>
</rss>
