<?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>OraStory &#187; oracle</title>
	<atom:link href="http://orastory.wordpress.com/category/oracle/feed/" rel="self" type="application/rss+xml" />
	<link>http://orastory.wordpress.com</link>
	<description>Dominic Brooks on Oracle - Data Quality, Sensible Design, SQL Performance</description>
	<lastBuildDate>Mon, 21 Dec 2009 12:02:36 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='orastory.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/f82b282aa91778f02f79157b5551b1a8?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>OraStory &#187; oracle</title>
		<link>http://orastory.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://orastory.wordpress.com/osd.xml" title="OraStory" />
		<item>
		<title>DBMS_XPLAN display issues</title>
		<link>http://orastory.wordpress.com/2009/12/21/dbms_xplan-display-issues/</link>
		<comments>http://orastory.wordpress.com/2009/12/21/dbms_xplan-display-issues/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 09:51:40 +0000</pubDate>
		<dc:creator>dombrooks</dc:creator>
				<category><![CDATA[dbms_xplan]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://orastory.wordpress.com/?p=435</guid>
		<description><![CDATA[DBMS_XPLAN is a great little tool for getting formatted SQL execution plans and associated information. Good enough to make my revised top 3 yesterday.
Whether following an explain plan:

EXPLAIN PLAN FOR
SELECT ... FORM ...;

SELECT *
FROM TABLE(DBMS_XPLAN.DISPLAY);

Or pulling a plan from memory using:

SELECT *
FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(&#60;sql_id&#62;,&#60;child_cursor&#62;,&#60;format&#62;));

Typically used with the gather_plan_statistics hint like this:

SELECT /*+ gather_plan_statistics */ ....
FROM ...
WHERE...;

SELECT [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=435&subd=orastory&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10577/d_xplan.htm#ARPLS70122">DBMS_XPLAN</a> is a great little tool for getting formatted SQL execution plans and associated information. Good enough to make <a href="http://orastory.wordpress.com/2009/12/19/top-3-oracle-features-of-the-decade/">my revised top 3 yesterday</a>.</p>
<p>Whether following an explain plan:</p>
<pre class="brush: plain;">
EXPLAIN PLAN FOR
SELECT ... FORM ...;

SELECT *
FROM TABLE(DBMS_XPLAN.DISPLAY);
</pre>
<p>Or pulling a plan from memory using:</p>
<pre class="brush: plain;">
SELECT *
FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(&lt;sql_id&gt;,&lt;child_cursor&gt;,&lt;format&gt;));
</pre>
<p>Typically used with the gather_plan_statistics hint like this:</p>
<pre class="brush: plain;">
SELECT /*+ gather_plan_statistics */ ....
FROM ...
WHERE...;

SELECT *
FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(NULL,NULL,'ALLSTATS LAST'));
</pre>
<p>Or pulling a plan still in memory by specifying the sql_id and, optionally, the child cursor.</p>
<p>For further information on the options for the third <em>format</em> parameter, here is <a href="http://rwijk.blogspot.com/2008/03/dbmsxplandisplaycursor.html">a nice post on Rob van Wijk&#8217;s blog</a>.</p>
<p>Jonathan Lewis also has some articles on dbms_xplan <a href="http://jonathanlewis.wordpress.com/2006/11/09/dbms_xplan-in-10g/">here</a> and <a href="http://jonathanlewis.wordpress.com/2008/03/06/dbms_xplan3/">here</a>.</p>
<p>Another handy option which I&#8217;ve been using recently is the ability to pull plans which are no longer in memory from the AWR repository using:</p>
<pre class="brush: plain;">
SELECT *
FROM TABLE(DBMS_XPLAN.DISPLAY_AWR(&lt;sql_id&gt;,&lt;child_cursor&gt;,&lt;db_id&gt;,&lt;format&gt;));
</pre>
<p>Whilst troubleshooting a recent performance problem where a good (all things are relative) plan had gone bad, the bad plan was no longer in memory. However, I was able to pull the bad plan from the AWR repository and also a number of variations on the good plan.</p>
<p>However, this was a big plan &#8211; some 3000 lines &#8211; and illustrates some display issues which you can get.</p>
<p>See this excerpt:</p>
<pre>
<font size="-2">
| 696 | BLE ACCESS BY INDEX ROWID                                 TA | POSITIONS                      |   4505 |
| 697 | NDEX RANGE SCAN                                            I | POSITIONS_IDX2                 |   4505 |
| 698 | DEX RANGE SCAN                                            IN | VEHICLE_RELATIONSHIPS_UK1      |      1 |
| 699 | E ACCESS BY INDEX ROWID                                 TABL | POSITIONS                      |        |
| 700 | EX RANGE SCAN                                            IND | POSITIONS_UK                   |      1 |
| 701 |                                                       FILTER |                                |        |
| 702 | D LOOPS                                                NESTE |                                |        |
| 703 | ED LOOPS                                                NEST |                                |      1 |
| 704 | TER                                                      FIL |                                |        |
| 705 | STED LOOPS OUTER                                          NE |                                |      1 |
| 706 | ABLE ACCESS BY INDEX ROWID                                 T | POSITIONS                      |   4505 |
| 707 |.INDEX RANGE SCAN                                             | POSITIONS_IDX2                 |   4505 |
| 708 | NDEX RANGE SCAN                                            I | VEHICLE_RELATIONSHIPS_UK1      |      1 |
| 709 | EX UNIQUE SCAN                                           IND | POSITIONS_PK                   |      1 |
| 710 | E ACCESS BY INDEX ROWID                                 TABL | POSITIONS                      |      1 |
</font>
</pre>
<p>The OUTPUT column is wrapped and does not make such investigations and interpretations any easier.<br />
Note that this is NOT a SQL*Plus display issue as far as I can work out. It&#8217;s not the whole line which is wrapping.</p>
<p>As far as I know, there is no solution to this.<br />
I have an Oracle SR open for confirmation but after 4 days I&#8217;ve yet to even receive confirmation of my ticket&#8230;</p>
<p>If there&#8217;s a solution, let me know.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orastory.wordpress.com/435/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orastory.wordpress.com/435/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orastory.wordpress.com/435/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orastory.wordpress.com/435/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orastory.wordpress.com/435/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orastory.wordpress.com/435/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orastory.wordpress.com/435/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orastory.wordpress.com/435/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orastory.wordpress.com/435/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orastory.wordpress.com/435/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=435&subd=orastory&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://orastory.wordpress.com/2009/12/21/dbms_xplan-display-issues/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">dombrooks</media:title>
		</media:content>
	</item>
		<item>
		<title>Top 3 Oracle Features of the Decade</title>
		<link>http://orastory.wordpress.com/2009/12/19/top-3-oracle-features-of-the-decade/</link>
		<comments>http://orastory.wordpress.com/2009/12/19/top-3-oracle-features-of-the-decade/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 21:48:49 +0000</pubDate>
		<dc:creator>dombrooks</dc:creator>
				<category><![CDATA[cbo]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://orastory.wordpress.com/?p=413</guid>
		<description><![CDATA[Yesterday I made an early break for the annual New Year resolutions post.
However, there&#8217;s another end-of-year post that&#8217;s up for consideration in this particular year and, rather than looking forward to the coming year, that&#8217;s a look back over the past 10, 2000-2010.
So, I ask you what are your top 3 Oracle RDBMS features over [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=413&subd=orastory&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://orastory.wordpress.com/2009/12/18/the-way-things-ar/">Yesterday</a> I made an early break for the annual New Year resolutions post.</p>
<p>However, there&#8217;s another end-of-year post that&#8217;s up for consideration in this particular year and, rather than looking forward to the coming year, that&#8217;s a look back over the past 10, 2000-2010.</p>
<p>So, I ask you what are your top 3 Oracle RDBMS features over the past decade.</p>
<p>Oracle 8i was 1999 so we&#8217;re really talking about:</p>
<ol>
<li><a href="http://download.oracle.com/docs/cd/A91202_01/901_doc/server.901/a90120/ch2_feat.htm#57493">9iR1</a> in 2001</li>
<li><a href="http://download.oracle.com/docs/cd/B10501_01/server.920/a96531/toc.htm">9iR2</a> in 2002</li>
<li><a href="http://download.oracle.com/docs/cd/B14117_01/server.101/b10750/toc.htm">10gR1</a> in 2003</li>
<li><a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14214/toc.htm">10gR2</a> in 2005</li>
<li><a href="http://download.oracle.com/docs/cd/B28359_01/server.111/b28279/toc.htm">11gR1</a> in 2007</li>
<li><a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e10881/toc.htm">11gR2</a> in 2009</li>
</ol>
<p>A Top 3 is very, very challenging when you think of some of the enhancements which have come along.</p>
<p>Obviously it depends on your own, personal perspective &#8211; naturally, mine are going to have a Development bias.</p>
<p>Each version fixes a significant number of bugs from the previous release, but I seem to remember 8i being a rush job for the buzzwords ahead of the new millenium (the early patches at least), 9iR1 a hatchet job and 9iR2 being a relative bastion of stability.</p>
<p>Then again it&#8217;s also a long time ago now and my memories may be unreliable.</p>
<p>The New Features Guides of 9i (links above) lists amongst others:</p>
<ul>
<li>LogMiner improvements, DataGuard, RAC, Flashback Query, Some online redefinition &amp; reorganisation features, VPD enhancements, Automatic Undo Management, dynamic memory management, spfles, RMAN improvements, native XML functionality and XMLDB, the MERGE statement, TIMESTAMPs and INTERVALs, CASE statement, External Tables, associative arrays/index-by tables indexed by VARCHAR2, Streams, CDC, Index Skip Scans, ANSI SQL, OMF, multiple blocksizes, dynamic sampling, table compression, subquery factoring, pipelined table functions, etc.</li>
</ul>
<p>A list of new features from 10g (or my list at least) is shorter, but even so it seems a bigger hitter in terms of weighty marketing-savvy acronyms and features:</p>
<ul>
<li>ADDM, ASH, ASM, AWR, Automatic SQL Tuning, DataPump, Job Scheduler, SQL Access Advisor, HTMLDB, Online Table Redefinition, Oracle XE, DBMS_XPLAN&#8230;</li>
</ul>
<p>11g has always felt like 10gR3. Nevertheless, there have been still some impressive features therein:</p>
<ul>
<li>Adaptive Cursor Sharing, Result Cache, Database Resident Connection Pool Caching, Invisible Indexes, SecureFiles, Binary XML&#8230;</li>
</ul>
<p>And then recently Exadata and the Oracle Database Machine (although I think it&#8217;s too soon to make any judgement on these and if they have a big impact then it will be mostly in the next decade).</p>
<p>For the summaries above, I&#8217;ve missed out a lot (probably accidentally &#8211; let me know &#8211; but I was rushing towards the end).</p>
<p>But I&#8217;ve focused on the initial introductions of headline new features.</p>
<p>However, I would argue that the gradual evolution of some of the main features and functionality has had some of the biggest impact as we are now at the end of the decade compared to the end of 1999. In addition, some of the tweaks and internals have also had a big impact whilst avoiding the headlines &#8211; mutexes for example.</p>
<p>Think about how the CBO has moved on over the past ten years. </p>
<p>Or how HTMLDB has morphed and moved on to APEX. </p>
<p>Or how parallel capabilities have developed. Or partitoning.</p>
<p>Maybe you like your GUIs like OEM.</p>
<p>Or the evolution of IDEs has been revolutionary for you e.g. SQL Developer, or the explosion of functionality in third party tools like Toad or Quest Code Tester for Oracle.</p>
<p>Or the combination of several features &#8211; external tables plus pipelined functions are pretty cool for loading in data, for example. Or partitioning plus parallel.</p>
<p>All of these are up for consideration.</p>
<p>What&#8217;s not up for consideration is stuff that predates the decade. There are several features which I thought of while doing this and which turned out to be introduced in 8i or even before. Man, tempus fugit&#8230;</p>
<p>So, my Top 3 is based on what  I do or use in Oracle most days (or even what I don&#8217;t have to do anymore) because of features introduced or evolved over the past decade. The evolution of collection functionality in SQL and PLSQL came close. A bit further behind was some of the XML capabilities. A whole host of ineligible features from older versions were scrubbed out. However, in no particular order, my vote goes to:</p>
<ul>
<li><del>Analytics &#8211; It&#8217;s amazing how many time I end up using analytic functions. As Tom Kyte says &#8220;Analytics rock, Analytics roll&#8221;. Countless multipasses of data have been avoided with these babies.</del>(Analytics ruled ineligible as an 8i introduction, dammit)</li>
<li>The WITH clause aka Subquery Factoring &#8211; Most of my sql, if it has any sort of complexity, ends up using this feature; fantastic for breaking up and understanding a complex bit of sql that you&#8217;ve never seen before; great at encouraging you to think in SETS.</li>
<li>AWR / ASH / Wait model evolution &#8211; Shame AWR &amp; ASH are licensed separately and there are alternatives for earlier Oracle versions or if you don&#8217;t want to fork out the big bucks. But so useful for diagnosing performance problems, particularly retrospectively and/or identifying session problems which might have drowned previously in a system-level Statspack. </li>
<li>DBMS_XPLAN &#8211; Another feature that I use day in, day out. So easy to get explain plans, actual plans from memory or from AWR. Invaluable!</li>
</ul>
<p>I would imagine that if you were a production DBA then the evolution of RMAN and Flashback has been fantastically useful and time saving.</p>
<p>These are not things that I&#8217;ve tended to use much in my role.</p>
<p>But if something&#8217;s revolutionised your decade, let me know.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orastory.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orastory.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orastory.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orastory.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orastory.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orastory.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orastory.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orastory.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orastory.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orastory.wordpress.com/413/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=413&subd=orastory&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://orastory.wordpress.com/2009/12/19/top-3-oracle-features-of-the-decade/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">dombrooks</media:title>
		</media:content>
	</item>
		<item>
		<title>The way things are</title>
		<link>http://orastory.wordpress.com/2009/12/18/the-way-things-ar/</link>
		<comments>http://orastory.wordpress.com/2009/12/18/the-way-things-ar/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 13:54:07 +0000</pubDate>
		<dc:creator>dombrooks</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://orastory.wordpress.com/?p=397</guid>
		<description><![CDATA[You wait for weeks for something to blog about then the basis for three or four articles come along at once.
Last week I was chatting by email to Chet, big bundle of enthusiasm that he is, about stuff, amongst other things, the lack of articles here. 
I&#8217;ve not fallen off the blog wagon but truth [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=397&subd=orastory&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>You wait for weeks for something to blog about then the basis for three or four articles come along at once.</p>
<p>Last week I was chatting by email to <a href="http://www.oraclenerd.com">Chet</a>, big bundle of enthusiasm that he is, about stuff, amongst other things, the lack of articles here. </p>
<p>I&#8217;ve not fallen off the blog wagon but truth is that for the past six months I&#8217;ve not really done any significant development work or performance tuning and that is what normally kicks off something to write about. </p>
<p>Plus I&#8217;m trying to avoid the sort of low-value, self-indulgent posts (like this one!) which tend to characterise this blog.</p>
<p>Due the economic downturn, the projects that I work on have gone into more of a maintenance mode so I&#8217;ve been somewhat under-utilised and have been doing more minor bug fixes, one line code changes and much, much less big development or tuning.</p>
<p>My heart is in development but small changes in no way float my boat. </p>
<p>It does make me think I should turn towards DBAdom and try and find DBA roles (and maybe it&#8217;s less roles but probably more company and departmental cultures) where the DBAs are <del datetime="2009-12-18T12:39:46+00:00">involved</del> welcomed into and are an integral part of the development process rather than find the sort of Development-focused roles that I&#8217;m struggling and have struggled to find recently.</p>
<p>The past couple of weeks I&#8217;ve been doing some work for a different team, giving me a change of perspective on the client&#8217;s business and data and giving everyone on the previous team a break from my attitude and tone (aggravated by my work frustrations).</p>
<p>No sooner have I moved over when the new team have got a SQL performance problem (not me, I haven&#8217;t touched anything).</p>
<p>The system is a model example of reusability and complexity, involving several of these:</p>
<ul>
<li>View -&gt; View -&gt; View -&gt; Pipelined Table function -&gt; View -&gt; View </li>
</ul>
<p>(i.e. look through the object definitions and you will see that the top level views references several other views which are themselves based on views, in turn based on pipelined-table functions which are based on views of views)<br />
(Reusability and complexity &#8211; or rather lack of complexity aka maintainability &#8211; can be two points on a trade-off triangle with the other being performance or cost)</p>
<p>The problem is a classic and I&#8217;m just working on the spin-off posts which touch (links to be updated shortly):</p>
<ul>
<li>&#8220;blind&#8221; investigating with AWR,</li>
<li>hinting,</li>
<li><a href="http://orastory.wordpress.com/2009/12/21/dbms_xplan-display-issues/">dbms_xplan display issues</a> and</li>
<li>troubleshooting big ugly plans.</li>
</ul>
<p>It&#8217;s the Friday before Christmas, I&#8217;m snowed in and working from home.<br />
<div id="attachment_399" class="wp-caption aligncenter" style="width: 310px"><a href="http://orastory.files.wordpress.com/2009/12/photo-5.jpg"><img src="http://orastory.files.wordpress.com/2009/12/photo-5.jpg?w=300&#038;h=225" alt="" title="Working from home" width="300" height="225" class="size-medium wp-image-399" /></a><p class="wp-caption-text">Is that a sled I see before me</p></div></p>
<p>I was just doing a half day (finished now of course) because:</p>
<ol>
<li>I find working remotely incredibly difficult without the two full screens I&#8217;ve become accustomed to, I have to remote onto my VM desktop at work where all my files are open via a less than full screen window, and half the open windows are on the second screen which I can&#8217;t see remotely;</li>
<li>the kids are here because snow has closed their school;</li>
<li>that sled in the photo is waiting for me.</li>
</ol>
<p>I was thinking also that I might be the first to make a break for this year&#8217;s New Year Resolutions post two weeks early (snow&#8217;s made me go scatty)&#8230;</p>
<p>In the New Year, I aspire to (in no particular order):</p>
<ul>
<li>Try to be a better person, parent, husband, friend and colleague.</li>
<li>Take more holidays.</li>
<li>Upgrade my certifications.</li>
<li>Find a more satisfying role.</li>
<li>Write better technical posts.</li>
<li>Write less low-value drivel.</li>
</ul>
<p>Have a good one.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orastory.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orastory.wordpress.com/397/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orastory.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orastory.wordpress.com/397/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orastory.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orastory.wordpress.com/397/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orastory.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orastory.wordpress.com/397/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orastory.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orastory.wordpress.com/397/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=397&subd=orastory&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://orastory.wordpress.com/2009/12/18/the-way-things-ar/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">dombrooks</media:title>
		</media:content>

		<media:content url="http://orastory.files.wordpress.com/2009/12/photo-5.jpg?w=300" medium="image">
			<media:title type="html">Working from home</media:title>
		</media:content>
	</item>
		<item>
		<title>Loader</title>
		<link>http://orastory.wordpress.com/2009/11/06/loader/</link>
		<comments>http://orastory.wordpress.com/2009/11/06/loader/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 17:11:13 +0000</pubDate>
		<dc:creator>dombrooks</dc:creator>
				<category><![CDATA[binary transfer]]></category>
		<category><![CDATA[delimiter]]></category>
		<category><![CDATA[external tables]]></category>
		<category><![CDATA[newline]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[sql*loader]]></category>

		<guid isPermaLink="false">http://orastory.wordpress.com/?p=389</guid>
		<description><![CDATA[It&#8217;s been years and years since I worked regularly with SQL*Loader-based feeds.
There are loads of tips and tricks regarding formats, encodings, character sets, etc.
I had forgotten nearly everything that I could ever have claimed to know in this area, all aged out of my personal buffer cache, at best distant memories, very distant.
However, I&#8217;ve recently [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=389&subd=orastory&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>It&#8217;s been years and years since I worked regularly with <a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e10713/cncptdba.htm#CNCPT1282">SQL*Loader</a>-based feeds.</p>
<p>There are loads of tips and tricks regarding formats, encodings, character sets, etc.<br />
I had forgotten nearly everything that I could ever have claimed to know in this area, all aged out of my personal buffer cache, at best distant memories, very distant.</p>
<p>However, I&#8217;ve recently had to resurrect some of these distant memories to feed some data via <a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e10713/tablecls.htm#CNCPT1141">External Tables</a>.</p>
<p>I thought it would be worthwhile to do an incoherent brain dump on some of the particular issues for future reference.</p>
<p>This article is my no means comprehensive and will just touch on some of the considerations specific to what I was doing.</p>
<p>The starting place for documentation on SQL*Loader is the <a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e10701/part_ldr.htm#i436326">Oracle Database Utilies Manual</a> and similarly for <a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e10701/part_et.htm#i436567">External Tables</a>.</p>
<p>The thing about external tables is that they can use the <a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e10701/et_params.htm#g1031955">ORACLE_LOADER<a> or the <a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e10701/et_dp_driver.htm#g1017944">ORACLE_DATAPUMP</a> access drivers.</p>
<p>My circumstances involved the ORACLE_LOADER driver.</p>
<p>As the names suggest, ORACLE_LOADER is related to SQL*LOADER. In fact, you can use the EXTERNAL_TABLE=GENERATE_ONLY parameter with SQL*LOADER to generate the syntax for your EXTERNAL TABLE.</p>
<p>I think things like this are brilliant but I never use them. I suppose I&#8217;m old skool. Neat features that auto generate code mean that a) I don&#8217;t necessarily need to understand what&#8217;s going on and b) skip the line-by-line sanity checks that I still believe in.</p>
<p>I work in an environment where it&#8217;s not so easy to get access to servers to ftp and view files, etc.</p>
<p>As a result, my approach would be to work with SQL*Loader early on and then graduate to external files nearer the time. However, I&#8217;m going to skip all that, fast forward past the SQL*Loader bit and move on to the issues.</p>
<p>So the main considerations for loading up data?<br />
- Encoding / Character sets<br />
- Delimiters &#8211; field and line<br />
- File Transfer</p>
<p>(I&#8217;m going to ignore <a href="http://en.wikipedia.org/wiki/Endianness">Endianness</a> for the sake of &#8220;clarity&#8221;.  But it can be a factor. See <a href="http://download-west.oracle.com/docs/cd/B10500_01/server.920/a96652/ch06.htm#1010633">Byte Ordering</a> for futher information.)</p>
<p>In my experience, when you get errors whilst loading, it&#8217;s due to one or more of the reasons above.<br />
More than one?<br />
Sure.</p>
<p>For example, the combination of file transfer mechanism and delimiters.<br />
Ever wondered why there&#8217;s confusion over whether you should transfer a file as text (or ascii), as binary? What&#8217;s the difference?</p>
<p>As ever, it depends.<br />
- SFTP doesn&#8217;t have a text mode, all transfers are binary.<br />
- FTP lets you choose between ascii (default) and binary.<br />
- What about WinSCP and similar tools with their automatic mode?</p>
<p>Automatic modes usually work off the file extension and would pick a text transfer for HTML, TXT, PHP, XML, etc and binary otherwise.</p>
<p>And the differences in mode?</p>
<p>For Text mode, there are two basic methods &#8211; either the tool is responsible for doing some conversion to the format supported by the destination or, more commonly, the client converts to a <a href="http://en.wikipedia.org/wiki/Canonical">canonical format</a> and the service then does a further conversion to its own format if necessary.</p>
<p>With Binary mode, the raw bytes are transferred as is, i.e. the file is transferred in its original form.</p>
<p>So, the main significance of this related to field and line delimiters &#8211; things like tabs and line feed characters are different between platforms, different between Unix and Windows for example.</p>
<p>This was particularly relevant for my file export from SQL Server to Oracle on Linux.</p>
<p>In Windows, a new line is often represented by two characters &#8211; one carriage return and one line feed.<br />
In Unix, a new line is normally just a line feed.</p>
<p>Sometimes you see &#8220;^M&#8221; characters on *nix. What&#8217;s this about?<br />
This represents the carriage return part of the newline for Windows as described above.<br />
If you need to, you can get rid of that using dos2unix.</p>
<p>So, in the ACCESS PARAMETERS subsection, if you use the &#8220;RECORDS DELIMITED BY NEWLINE&#8221; syntax in your external table definiton, what does that mean?</p>
<p>The NEWLINE keyword uses the newline format for your platform &#8211; so just a line feed in the case of *nix.</p>
<p>For my process, I decided that I would just go with the format as extracted from SQL Server &#8211; a 50:50 decision that there&#8217;s no point on expanding on.</p>
<p>So, in my situation, the syntax for an external table should not use the NEWLINE keyword because the format was Windows new lines, the syntax for which can be: </p>
<pre class="brush: plain;">
RECORDS DELIMITED BY '\r\n'
</pre>
<p>Here&#8217;s a situation. Things have been going fine in DEV,etc and eventually go to PREPRODUCTION and there&#8217;s a problem.</p>
<p>The feeds don&#8217;t work. The external table loader isn&#8217;t finding the right delimiters.</p>
<p>The question really is how can you tell what characters are in your file?<br />
So, there&#8217;s no point looking at the file prior to transfer in case the technological clue (or the person in a manual process) changes the file on transfer.  We need to look at it in the destination directory on the destination server.</p>
<p>And what&#8217;s the best way to do that?</p>
<p>On a Unix/Linux, a useful command is the od command which dumps files in octal and other formats. For example,</p>
<pre class="brush: plain;">
od -c &lt;filename&gt;
</pre>
<p>which gives ascii characters or backslash escapes.<br />
There&#8217;s a lot of output from this command but you don&#8217;t need to do the whole file, e.g.</p>
<pre class="brush: plain;">
head -2 &lt;filename&gt; | od -x | more
</pre>
<p>If the file suddenly doesn&#8217;t match the expected format, what&#8217;s the sort of errors you might get?<br />
Well, if it should have transfered in binary but it was done in text by error, you might get:</p>
<pre class="brush: plain;">
KUP-04020: found record longer than buffer size supported
</pre>
<p>i.e. the lines are running into each other<br />
or under slightly different circumstances</p>
<pre class="brush: plain;">
KUP-04023: field start is after end of record
</pre>
<p>etc.</p>
<p>That&#8217;s about it on transfers and delimiters.</p>
<p>What&#8217;s there to say about encoding and character sets.<br />
Using the od command above we can see the hex codes to double check the encoding is as expected.<br />
Other that that, in our external table definition we can specify the character set in the ACCESS PARAMETERS section using the CHARACTERSET keyword, e.g.</p>
<pre class="brush: plain;">
CREATE TABLE &lt;my_tablename&gt;
(&lt;my_columns&gt;)
ORGANIZATION EXTERNAL
  (  TYPE ORACLE_LOADER
     DEFAULT DIRECTORY &lt;my_directory&gt;
     ACCESS PARAMETERS
       ( RECORDS DELIMITED BY '\r\n'
       CHARACTERSET AL16UTF16
       FIELDS TERMINATED BY '\t'
       MISSING FIELD VALUES ARE NULL  )
     LOCATION (&lt;my_directory&gt;:'&lt;my_filename&gt;')
  )
REJECT LIMIT 0;
</pre>
<p>and then the expected characterset conversion will take place.<br />
Note that SQLServer tends to use USC2 as its unicode characterset and UCS2 is a subset of AL16UTF16.</p>
<p>It&#8217;s Friday, it&#8217;s 5 o&#8217;clock, I&#8217;ve lost focus. I&#8217;m done.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orastory.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orastory.wordpress.com/389/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orastory.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orastory.wordpress.com/389/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orastory.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orastory.wordpress.com/389/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orastory.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orastory.wordpress.com/389/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orastory.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orastory.wordpress.com/389/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=389&subd=orastory&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://orastory.wordpress.com/2009/11/06/loader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">dombrooks</media:title>
		</media:content>
	</item>
		<item>
		<title>Learning</title>
		<link>http://orastory.wordpress.com/2009/10/28/learning/</link>
		<comments>http://orastory.wordpress.com/2009/10/28/learning/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 12:11:30 +0000</pubDate>
		<dc:creator>dombrooks</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://orastory.wordpress.com/?p=380</guid>
		<description><![CDATA[Earlier this month I attended Tanel Poder&#8217;s course &#8220;Advanced Oracle Troubleshooting for DBAs and Performance Engineers&#8221;.
It was good &#8211; definitely worthwhile, lots of useful information and really puts into perspective those scripts of his, like LatchProf, LatchProfX, WaitProf and sample.sql. Plus a whole bunch of other stuff. So definitely worth thinking about if you&#8217;ve any [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=380&subd=orastory&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Earlier this month I attended <a href="http://blog.tanelpoder.com">Tanel Poder</a>&#8217;s course <a href="http://miraclebenelux.nl/index.php?option=com_content&amp;view=article&amp;id=50:tanelpoderevent">&#8220;Advanced Oracle Troubleshooting for DBAs and Performance Engineers&#8221;</a>.</p>
<p>It was good &#8211; definitely worthwhile, lots of useful information and really puts into perspective those scripts of his, like <a href="http://blog.tanelpoder.com/2008/08/26/flexible-sampling-of-any-v-or-x-view-with-samplesql/">LatchProf, LatchProfX, WaitProf and sample.sql.</a> Plus <a href="http://blog.tanelpoder.com/seminar/seminar-files/">a whole bunch of other stuff</a>. So definitely worth thinking about if you&#8217;ve any training budget (that&#8217;s mine blown for forseeable future).</p>
<p>I&#8217;ve already mentioned the <a href="http://orastory.wordpress.com/2009/09/16/metalink-headlines/">Metalink Headlines</a> tip and I&#8217;ve had a little jump in traffic over the past couple of days from <a href="http://blog.tanelpoder.com/2009/10/26/whats-a-good-way-to-learn-some-oracle-internals-every-day/">Tanel saying the same thing</a>.</p>
<p>The other top tip was to read <a href="http://jamesmorle.wordpress.com/">James Morle</a>&#8217;s book <a href="http://www.scaleabilities.co.uk/index.php/Books/">Scaling Oracle 8i</a>. James was there on the second day but that wasn&#8217;t why it was recommended. Ignore the 8i in the title, most of it remains as relevant as it ever was. I don&#8217;t know how I never read this at the time but I&#8217;m ploughing through it on the train and it&#8217;s a real, real benefit. It&#8217;s not just about Oracle. It&#8217;s as much about the stuff it interacts with &#8211; OS, IO subsystems, memory, etc.<br />
It&#8217;s downloadable. Read it.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orastory.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orastory.wordpress.com/380/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orastory.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orastory.wordpress.com/380/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orastory.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orastory.wordpress.com/380/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orastory.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orastory.wordpress.com/380/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orastory.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orastory.wordpress.com/380/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=380&subd=orastory&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://orastory.wordpress.com/2009/10/28/learning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">dombrooks</media:title>
		</media:content>
	</item>
		<item>
		<title>Metalink headlines</title>
		<link>http://orastory.wordpress.com/2009/09/16/metalink-headlines/</link>
		<comments>http://orastory.wordpress.com/2009/09/16/metalink-headlines/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 09:51:50 +0000</pubDate>
		<dc:creator>dombrooks</dc:creator>
				<category><![CDATA[Metalink]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://orastory.wordpress.com/?p=364</guid>
		<description><![CDATA[When I was thinking about whether to go on Tanel Poder&#8217;s course, I read the testimonials and there&#8217;s a great piece of advice from Tanel via Coskan Gundogar:

I asked him how do you learn all these interesting stuff. He gave me a perfect clue. Sign up for metalink headlines mailing list. Bugs docs they are [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=364&subd=orastory&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>When I was thinking about whether to go on <a href="http://blog.tanelpoder.com">Tanel Poder&#8217;s</a> <a href="http://www.miraclebenelux.nl/index.php?option=com_content&amp;view=article&amp;id=50&amp;Itemid=12">course</a>, I read the testimonials and there&#8217;s a great piece of advice from Tanel <a href="http://coskan.wordpress.com/2009/04/30/what-i-learned-from-aot-by-tanel-poder/">via Coskan Gundogar</a>:</p>
<blockquote><p>
I asked him how do you learn all these interesting stuff. He gave me a perfect clue. Sign up for metalink headlines mailing list. Bugs docs they are all there after they are created. Perfect resource.
</p></blockquote>
<p>I just want to emphasise what a great resource these Metalink updates are.</p>
<p>I&#8217;ve only been signed up for a couple of weeks but some of the nuggets that come into your mailbox are pure gold.</p>
<p>I&#8217;ve learnt some stuff that I would never come across, plus I&#8217;m building up links for some great articles and explanations, some of which are invaluable as a reference for yourself or to give others (I&#8217;m rubbish at explaining stuff in my own words).</p>
<p>For example, just from the last couple of days, I&#8217;ve been notified of these new or updated articles:<br />
(Note: Login to Metalink first before clicking the links)</p>
<p>Character set and character set conversion (comes up all the time on the forums and from other teams at work):</p>
<ul>
<li>260893.1: <a href="https://metalink.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;id=260893.1">Unicode Character Sets In The Oracle Database</a></li>
<li>158577.1: <a href="https://metalink.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;id=158577.1">NLS_LANG explained</a></li>
</ul>
<p>Metalink Scripts:</p>
<ul>
<li>131704.1: <a href="https://metalink.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;id=131704.1">Database Scripts Library Index</a></li>
</ul>
<p>General:</p>
<ul>
<li>783357.1: <a href="https://metalink.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;id=783357.1">Troubleshooting DBMS_SCHEDULER and DBMS_JOB</a></li>
</ul>
<p>Interesting behaviour:</p>
<ul>
<li>887553.1: <a href="https://metalink.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;id=887553.1">Join elimination does not happen for Composite Foregin key</a></li>
</ul>
<p>To name but a few&#8230;</p>
<p>It&#8217;s just invaluable stuff. </p>
<p>Sign up if you don&#8217;t already.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orastory.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orastory.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orastory.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orastory.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orastory.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orastory.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orastory.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orastory.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orastory.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orastory.wordpress.com/364/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=364&subd=orastory&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://orastory.wordpress.com/2009/09/16/metalink-headlines/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">dombrooks</media:title>
		</media:content>
	</item>
		<item>
		<title>Data modelling in the modern world</title>
		<link>http://orastory.wordpress.com/2009/08/06/data-modelling-in-the-modern-world/</link>
		<comments>http://orastory.wordpress.com/2009/08/06/data-modelling-in-the-modern-world/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 15:10:29 +0000</pubDate>
		<dc:creator>dombrooks</dc:creator>
				<category><![CDATA[agile]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://orastory.wordpress.com/?p=359</guid>
		<description><![CDATA[I first read Robyn Sands&#8217;s article on the importance of a good data model back when it was published in May.
However, the comments have since moved on and taken a life of their own &#8211; a sure sign of a great post &#8211; with some excellent points and poignant observations on the frequent neglect of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=359&subd=orastory&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I first read <a href="http://adhdocddba.blogspot.com/2009/05/on-importance-of-good-data-model.html">Robyn Sands&#8217;s article on the importance of a good data model</a> back when it was published in May.</p>
<p>However, the comments have since moved on and taken a life of their own &#8211; a sure sign of a great post &#8211; with some excellent points and poignant observations on the frequent neglect of the data model in the agile world.</p>
<p>If you&#8217;ve not read it or have not kept updated with the comments, then I urge you to.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orastory.wordpress.com/359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orastory.wordpress.com/359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orastory.wordpress.com/359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orastory.wordpress.com/359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orastory.wordpress.com/359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orastory.wordpress.com/359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orastory.wordpress.com/359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orastory.wordpress.com/359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orastory.wordpress.com/359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orastory.wordpress.com/359/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=359&subd=orastory&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://orastory.wordpress.com/2009/08/06/data-modelling-in-the-modern-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">dombrooks</media:title>
		</media:content>
	</item>
		<item>
		<title>Gotcha: Application Contexts</title>
		<link>http://orastory.wordpress.com/2009/07/14/gotcha-application-contexts/</link>
		<comments>http://orastory.wordpress.com/2009/07/14/gotcha-application-contexts/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 10:12:04 +0000</pubDate>
		<dc:creator>dombrooks</dc:creator>
				<category><![CDATA[11.1.0.7]]></category>
		<category><![CDATA[context]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[sys_context]]></category>

		<guid isPermaLink="false">http://orastory.wordpress.com/?p=355</guid>
		<description><![CDATA[This is one of those feature behaviours which isn&#8217;t surprising, but you probably wouldn&#8217;t think about it unless you saw it.
The flop:
I make heavy use of application contexts in flexible, variable input, dynamically-built queries (one of the options mentioned in this asktom thread for example).
(In the latest edition of Oracle Magazine, Tom explains why this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=355&subd=orastory&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This is one of those feature behaviours which isn&#8217;t surprising, but you probably wouldn&#8217;t think about it unless you saw it.</p>
<p><strong>The flop:</strong></p>
<p>I make heavy use of <a href="http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/functions172.htm#SQLRF06117">application contexts</a> in flexible, variable input, dynamically-built queries (one of the options mentioned in <a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:104931400346587790">this asktom thread</a> for example).</p>
<p>(In the <a href="http://www.oracle.com/technology/oramag/oracle/09-jul/index.html">latest edition of Oracle Magazine</a>, <a href="http://www.oracle.com/technology/oramag/oracle/09-jul/o49asktom.html">Tom explains</a> why this is not an approach he would recommend any more. I don&#8217;t necessarily agree but more of that another time perhaps)</p>
<p><strong>The Turn:</strong></p>
<p>My Query Builder &#8211; a set of code which I&#8217;ve always intended to make publicly available but have yet to do so &#8211; uses a context with single namespace and typically reuses attribute names between queries &#8211; e.g. a product id populated from an on-screen product selector will typically populate a context attribute called PRODUCT_ID.</p>
<p>And a Query Builder implementation will typically reset any context attributes(DBMS_SESSION.CLEAR_ALL_CONTEXT) at the start to clear any parameters from a previous query.</p>
<p>In one of the more complex scenarios, a controller proc constructs three different queries, based on the input parameters supplied, in order to return three resultsets to populate three different parts of a GUI. A bit like this dummy code:</p>
<pre class="brush: plain;">
CREATE OR REPLACE PROCEDURE p_get_matching_data (
  i_parameters             IN  some_array_type
  o_cursor1                 OUT SYS_REFCURSOR,
  o_cursor2                 OUT SYS_REFCURSOR,
  o_cursor3                 OUT SYS_REFCURSOR
)
AS
   l_query1 LONG;
   l_query2 LONG;
   l_query3 LONG;
BEGIN
   l_query1 := my_query_builder_pkg.build_query1(i_parameters);
   OPEN o_cursor1 FOR l_query1;
   l_query2 := my_query_builder_pkg.build_query2(i_parameters);
   OPEN o_cursor2 FOR l_query2;
   l_query3 := my_query_builder_pkg.build_query3(i_parameters);
   OPEN o_cursor3 FOR l_query3;
END;
</pre>
<p><strong>The River:</strong></p>
<p>The problem with SYS_CONTEXT is that it is not bound into the query like a bind variable, nor is it subject to the same read consistency mechanism as block data.</p>
<p>Witness:</p>
<pre class="brush: plain;">
DOMINIC@11gR1&amp;gt;VAR r REFCURSOR
DOMINIC@11gR1&amp;gt;CREATE CONTEXT demo_ctx USING context_demo_pkg;

Context created.

Elapsed: 00:00:00.00
DOMINIC@11gR1&amp;gt;CREATE OR REPLACE PACKAGE context_demo_pkg
  2  AS
  3    --
  4    PROCEDURE p_set_context (
  5      i_attribute                IN     VARCHAR2,
  6      i_value                    IN     VARCHAR2
  7    );
  8    --
  9    PROCEDURE p_unset_context (
 10      i_attribute                IN     VARCHAR2
 11    );
 12    --
 13  END;
 14  /

Package created.

Elapsed: 00:00:00.00
DOMINIC@11gR1&amp;gt;CREATE OR REPLACE PACKAGE BODY context_demo_pkg
  2  AS
  3    --
  4    k_namespace CONSTANT VARCHAR2(24) := 'DEMO_CTX';
  5    --
  6    PROCEDURE p_set_context (
  7      i_attribute                IN     VARCHAR2,
  8      i_value                    IN     VARCHAR2
  9    )
 10    AS
 11    BEGIN
 12       --
 13       DBMS_SESSION.SET_CONTEXT
 14       (namespace =&amp;gt; k_namespace,
 15        attribute =&amp;gt; i_attribute,
 16        value     =&amp;gt; i_value);
 17       --
 18    END p_set_context;
 19    --
 20    PROCEDURE p_unset_context (
 21      i_attribute                IN     VARCHAR2
 22    )
 23    AS
 24    BEGIN
 25       --
 26       DBMS_SESSION.CLEAR_CONTEXT
 27       (namespace =&amp;gt; k_namespace,
 28        attribute =&amp;gt; i_attribute);
 29       --
 30    END p_unset_context;
 31    --
 32  END;
 33  /

Package body created.

Elapsed: 00:00:00.00
DOMINIC@11gR1&amp;gt;
</pre>
<p>Now to demonstrate the different behaviour.</p>
<p>The bind variable:</p>
<pre class="brush: plain;">
DOMINIC@11gR1&amp;gt;DECLARE
  2   l_value  varchar2(24) := 'My Test Bind';
  3  BEGIN
  4    open :r for select l_value from dual;
  5    l_value := null;
  6  END;
  7  /

PL/SQL procedure successfully completed.

:B1
--------------------------------
My Test Bind

Elapsed: 00:00:00.00
DOMINIC@11gR1&amp;gt;
</pre>
<p>No surprises there.<br />
Now the illustration of read consistency:</p>
<pre class="brush: plain;">
DOMINIC@11gR1&amp;gt;CREATE TABLE test_data
  2  (col1 VARCHAR2(1));

Table created.

Elapsed: 00:00:01.02
DOMINIC@11gR1&amp;gt;
DOMINIC@11gR1&amp;gt;INSERT
  2  INTO   test_data
  3  VALUES ('A');

1 row created.

Elapsed: 00:00:00.00
DOMINIC@11gR1&amp;gt;BEGIN
  2     OPEN :r FOR SELECT * FROM test_data;
  3     DELETE FROM test_data;
  4     COMMIT;
  5  END;
  6  /

PL/SQL procedure successfully completed.

C
-
A

Elapsed: 00:00:00.00
DOMINIC@11gR1&amp;gt;
</pre>
<p>Again, no surprises. Read consistency around cursor opening/fetching as you might expect.<br />
Next, the application context.</p>
<p>Firstly, just to prove that it works:</p>
<pre class="brush: plain;">
DOMINIC@11gR1&amp;gt;BEGIN
  2     context_demo_pkg.p_set_context('VALUE1','My Test Bind');
  3     OPEN :r FOR SELECT SYS_CONTEXT('DEMO_CTX','VALUE1') FROM dual;
  4  END;
  5  /

PL/SQL procedure successfully completed.

SYS_CONTEXT('DEMO_CTX','VALUE1')
-------------------------------------
My Test Bind

Elapsed: 00:00:00.00
DOMINIC@11gR1&amp;gt;
</pre>
<p>But if we reset it before we fetch from the cursor:</p>
<pre class="brush: plain;">
DOMINIC@11gR1&amp;gt;BEGIN
  2     context_demo_pkg.p_set_context('VALUE1','My Test Bind');
  3     OPEN :r FOR SELECT SYS_CONTEXT('DEMO_CTX','VALUE1') FROM dual;
  4     context_demo_pkg.p_unset_context('VALUE1');
  5  END;
  6  /

PL/SQL procedure successfully completed.

SYS_CONTEXT('DEMO_CTX','VALUE1')
---------------------------------------

Elapsed: 00:00:00.00
DOMINIC@11gR1&amp;gt;
</pre>
<p>So, once you see it, not entirely unsurprising but maybe not something that you&#8217;d considered before ( I hadn&#8217;t ). Behaviour neither like a bind nor read consistency like block data.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orastory.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orastory.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orastory.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orastory.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orastory.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orastory.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orastory.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orastory.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orastory.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orastory.wordpress.com/355/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=355&subd=orastory&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://orastory.wordpress.com/2009/07/14/gotcha-application-contexts/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">dombrooks</media:title>
		</media:content>
	</item>
		<item>
		<title>Madness</title>
		<link>http://orastory.wordpress.com/2009/05/29/madness/</link>
		<comments>http://orastory.wordpress.com/2009/05/29/madness/#comments</comments>
		<pubDate>Fri, 29 May 2009 14:44:03 +0000</pubDate>
		<dc:creator>dombrooks</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://orastory.wordpress.com/?p=345</guid>
		<description><![CDATA[Just a quick one&#8230;
Had a meeting request today to get an idea of the different authorisation groups that will be required when in the future we move to a model that carries the authorisation ACL with the data.
This is a part of an ongoing architectural initiative to turn a logic-heavy database effectively into a bit [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=345&subd=orastory&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Just a quick one&#8230;</p>
<p>Had a meeting request today to <em>get an idea of the different authorisation groups that will be required when in the future we move to a model that carries the authorisation ACL with the data</em>.</p>
<p>This is a part of an ongoing architectural initiative to turn a logic-heavy database effectively into a bit bucket. </p>
<p>I know these things are going on all the time everywhere in a quasi-religious battle.<br />
I know I&#8217;ve talked about it before as have many others elsewhere.<br />
I&#8217;m sure I resolved to let it wash over me and not to get bothered by it or get sucked into battles I can&#8217;t win.</p>
<p>But this is madness this aspiration that this database, probably one of the most expensive bits of this tech stack, should be reduced to a bit bucket at some point in the future.</p>
<p>With the middle tier doing the data joining&#8230;</p>
<p>The middle tier doing what should be the set operations in the database in some sort of horrific giant nested loop operation&#8230;</p>
<p>And the middle tier doing the data security, which should be right there with the data in the database.</p>
<p>It&#8217;s a mad world.</p>
<p>And in today&#8217;s economic climate, this can&#8217;t be what they mean by &#8220;doing more for less&#8221;.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orastory.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orastory.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orastory.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orastory.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orastory.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orastory.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orastory.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orastory.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orastory.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orastory.wordpress.com/345/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=345&subd=orastory&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://orastory.wordpress.com/2009/05/29/madness/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">dombrooks</media:title>
		</media:content>
	</item>
		<item>
		<title>YAGNI?</title>
		<link>http://orastory.wordpress.com/2009/05/14/yagni/</link>
		<comments>http://orastory.wordpress.com/2009/05/14/yagni/#comments</comments>
		<pubDate>Thu, 14 May 2009 20:47:20 +0000</pubDate>
		<dc:creator>dombrooks</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[yagni]]></category>

		<guid isPermaLink="false">http://orastory.wordpress.com/?p=338</guid>
		<description><![CDATA[YAGNI, it&#8217;s a very common term in development teams these days. Overused even.
However, in today&#8217;s more austere and economically challenging times, I have some new acronyms for you.
I&#8217;m not really up on popular acronyms so these may already exist in some form or another, but here are some more appropriate sayings that I&#8217;m saying/seeing more [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=338&subd=orastory&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://en.wikipedia.org/wiki/You_Ain%27t_Gonna_Need_It">YAGNI</a>, it&#8217;s a very common term in development teams these days. Overused even.</p>
<p>However, in today&#8217;s more austere and economically challenging times, I have some new acronyms for you.</p>
<p>I&#8217;m not really up on popular acronyms so these may already exist in some form or another, but here are some more appropriate sayings that I&#8217;m saying/seeing more and more, together especially:</p>
<p>I Do Bloody Well Need It (IBLOWENI &#8211; ha ha) &#8230; but &#8230; NO-one&#8217;s Gonna Pay For It (NOGOPAFI).</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orastory.wordpress.com/338/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orastory.wordpress.com/338/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orastory.wordpress.com/338/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orastory.wordpress.com/338/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orastory.wordpress.com/338/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orastory.wordpress.com/338/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orastory.wordpress.com/338/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orastory.wordpress.com/338/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orastory.wordpress.com/338/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orastory.wordpress.com/338/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orastory.wordpress.com&blog=672199&post=338&subd=orastory&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://orastory.wordpress.com/2009/05/14/yagni/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">dombrooks</media:title>
		</media:content>
	</item>
	</channel>
</rss>