<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7198004864285840789</id><updated>2011-04-21T19:29:47.389-07:00</updated><title type='text'>Potkin's Oracle Notes</title><subtitle type='html'>I have been earning my dough from my knowledge of Oracle since 1989, when it was version 5. So much has changed and so many new topics have arrived that I thought I use the weblog technology to note down little tips and problems I come across during my daily work with Oracle</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>55</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-6907915951837360108</id><published>2009-04-20T07:42:00.001-07:00</published><updated>2009-04-20T07:47:25.019-07:00</updated><title type='text'>Flahsback Database and Roll Forward</title><content type='html'>Following up on the previous post, now suppose the table is lost but you do not want to rollback the entire database to prior to the loss.&lt;br /&gt;This is a clever way of doing this but it means living with the truncated table until some downtime is available.&lt;br /&gt;&lt;br /&gt;Flashback until the appropriate time as outlined in the previous post. Then open the database read-only and not open resetlogs. Export the table before the loss occured. After the export is completed issue a RECOVER DATABASE command, so Oracle fast forwards to the time of clean shutdown. Open the database and then import back the Table. Thus you have the table before data was lost without having flashed back the entire database.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-6907915951837360108?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/6907915951837360108/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=6907915951837360108' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/6907915951837360108'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/6907915951837360108'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2009/04/flahsback-database-and-roll-forward.html' title='Flahsback Database and Roll Forward'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-6355378574619921913</id><published>2009-04-20T05:54:00.000-07:00</published><updated>2009-04-20T07:37:20.567-07:00</updated><title type='text'>Restore the Entire Database with Flashback</title><content type='html'>Don't know how this will work on a large database, but looks like the easiest way to restore the entire Oracle database. On a home grown database, 3GB, it took just a few seconds.&lt;br /&gt;&lt;br /&gt;SQL&gt; shutdown immediate;&lt;br /&gt;Database closed.&lt;br /&gt;Database dismounted.&lt;br /&gt;ORACLE instance&lt;br /&gt;shut down.&lt;br /&gt;&lt;br /&gt;SQL&gt; startup mount exclusive;&lt;br /&gt;ORACLE instance started.&lt;br /&gt;Database mounted.&lt;br /&gt;&lt;br /&gt;SQL&gt; FLASHBACK DATABASE to timestamp to_timestamp('20-04-2009 10:00', 'DD-MM-YYYY HH24:MI:SS');&lt;br /&gt;Flashback complete.&lt;br /&gt;&lt;br /&gt;SQL&gt; alter database open resetlogs;&lt;br /&gt;&lt;br /&gt;If on the other hand you are ok to just recover the database to the last scn, for example a Table has been accidentally truncated in a DWH, and no transactional activity had taken place before the truncate, you can recover the database back to the scn, using Flashback by&lt;br /&gt;&lt;br /&gt;sql&gt; select current_scn from v$database;&lt;br /&gt;&lt;br /&gt;Current SCN&lt;br /&gt;------------&lt;br /&gt;2592544&lt;br /&gt;&lt;br /&gt;Table truncated&lt;br /&gt;&lt;br /&gt;sql&gt; Connect / as sysdba&lt;br /&gt;connected.&lt;br /&gt;&lt;br /&gt;sql&gt;shutdown immediate;&lt;br /&gt;Database closed.&lt;br /&gt;Database dismounted&lt;br /&gt;ORACLE instance shutdown.&lt;br /&gt;&lt;br /&gt;sql&gt; Startup Mount;&lt;br /&gt;&lt;br /&gt;sql&gt;flashback database to scn 2592544;&lt;br /&gt;Flashback complete&lt;br /&gt;&lt;br /&gt;sql&gt; alter database open resetlogs;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-6355378574619921913?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/6355378574619921913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=6355378574619921913' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/6355378574619921913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/6355378574619921913'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2009/04/restore-entire-database-with-flashback.html' title='Restore the Entire Database with Flashback'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-6454561025651644255</id><published>2009-04-17T01:41:00.000-07:00</published><updated>2009-04-17T01:46:46.052-07:00</updated><title type='text'>RMAN Correct Syntax for Until Time Restore</title><content type='html'>As brilliant as the book by Matthew Hart and Scott Jesse on High Availability with Oracle 10g RAC is, there are some unfortunate syntax errors which shouldn't be there.&lt;br /&gt;&lt;br /&gt;For example on pp 304, the correct syntax for when specifying a point in time to recover from with RMAN should read as follows:&lt;br /&gt;&lt;br /&gt;RMAN&gt; run {&lt;br /&gt;               set until time "to_date('04-NOV-2003 12:00:00', 'DD-MON-YYYY hh24:mi:ss')";&lt;br /&gt;               restore database;&lt;br /&gt;               recover database;&lt;br /&gt;              }&lt;br /&gt;&lt;br /&gt;and not the way it is printed in the book.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-6454561025651644255?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/6454561025651644255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=6454561025651644255' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/6454561025651644255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/6454561025651644255'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2009/04/rman-correct-syntax-for-until-time.html' title='RMAN Correct Syntax for Until Time Restore'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-8629011487373133074</id><published>2009-02-17T07:21:00.000-08:00</published><updated>2009-04-17T01:41:11.009-07:00</updated><title type='text'>Installing Oracle 10g on SUSE10</title><content type='html'>Had problem installing Oracle10g on a Linux server using SUSE10 O/S. The installation file only seems to think Oracle is certified to be installed on SUSE9. To get round the problem run the install file with the following option:&lt;br /&gt;&lt;br /&gt;./runInstaller -ignoreSysPrereqs&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-8629011487373133074?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/8629011487373133074/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=8629011487373133074' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/8629011487373133074'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/8629011487373133074'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2009/02/installing-oracle-10g-on-suse10.html' title='Installing Oracle 10g on SUSE10'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-5064266026695749531</id><published>2009-02-17T07:14:00.000-08:00</published><updated>2009-02-17T07:19:46.941-08:00</updated><title type='text'>What Metadata is the MicroStrategy Project Source Connected to?</title><content type='html'>There is nothing from the GUI inetrface that tells you what metadata DSN your Microstrategy Project Source is connected to. This is one way of finding out however:&lt;br /&gt;&lt;br /&gt;In order to determine which DSN is being used by Intelligence Server for metadata connectivity, navigate to the following registry key shown below:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;HKEY_LOCAL_MACHINE&gt;SOFTWARE&gt;MicroStrategy&gt;Data Sources&gt;Castor Server&gt;Location&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;and see the value.&lt;br /&gt;This has to be done on the machine where the Intelligence Server is.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-5064266026695749531?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/5064266026695749531/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=5064266026695749531' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/5064266026695749531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/5064266026695749531'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2009/02/what-metadata-is-microstrategy-project.html' title='What Metadata is the MicroStrategy Project Source Connected to?'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-2449535870177850805</id><published>2008-06-30T02:52:00.000-07:00</published><updated>2008-06-30T03:00:34.797-07:00</updated><title type='text'>Narrowcast Server Does Not Start After Password Change</title><content type='html'>After changing the windows account password, a user cannot the start the MicroStrategy Narrowcast Server 8.x system.&lt;br /&gt;&lt;br /&gt;The following two services have to be updated with the new password:&lt;br /&gt;MicroStrategy Distribution Manager and the MicroStrategy Execution Engine services&lt;br /&gt;&lt;br /&gt;Right click on the above services and chose properties. Then update the passwords under the Log On tab.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-2449535870177850805?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/2449535870177850805/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=2449535870177850805' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2449535870177850805'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2449535870177850805'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2008/06/narrowcast-server-does-not-start-after.html' title='Narrowcast Server Does Not Start After Password Change'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-9165487294970044860</id><published>2008-02-05T06:29:00.000-08:00</published><updated>2008-02-05T06:39:09.617-08:00</updated><title type='text'>MicroStrategy Narrowcast Tips</title><content type='html'>Examining the DELog*.txt files in:&lt;br /&gt;&lt;br /&gt;C:\Program Files\MicroStrategy\Narrowcast Server\Delivery Engine&lt;br /&gt;&lt;br /&gt;is slightly easier than the entire message log. Copy the service id of the Service name you are investigating and search the relevant file in the above folder to trace the events associated with the service.&lt;br /&gt;&lt;br /&gt;If there are pre/post SQL scripts, open up the Subscription Set editor, then from the menu&lt;br /&gt;Edit -&gt; Subscription Set properties.&lt;br /&gt;&lt;br /&gt;pre/post SQL scripts on the subscription sets can also be used to determine for example if an ETL Completion flag is set so that NC Services can be run.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-9165487294970044860?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/9165487294970044860/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=9165487294970044860' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/9165487294970044860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/9165487294970044860'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2008/02/microstrategy-narrowcast-tips.html' title='MicroStrategy Narrowcast Tips'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-1972215853438782442</id><published>2007-10-05T10:03:00.000-07:00</published><updated>2007-10-05T10:08:34.500-07:00</updated><title type='text'>Creating Oracle Table Varray Data Type Columns</title><content type='html'>Best explained reference to this with easy examples can be found here:&lt;br /&gt;&lt;br /&gt;PART I&lt;br /&gt;&lt;a href="http://blogs.ittoolbox.com/database/solutions/archives/working-with-varrays-in-oracle-part-i-9111"&gt;http://blogs.ittoolbox.com/database/solutions/archives/working-with-varrays-in-oracle-part-i-9111&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;PART II&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blogs.ittoolbox.com/database/solutions/archives/working-with-varrays-in-oracle-part-ii-9229"&gt;http://blogs.ittoolbox.com/database/solutions/archives/working-with-varrays-in-oracle-part-ii-9229&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;PART III&lt;br /&gt;&lt;a href="http://blogs.ittoolbox.com/database/solutions/archives/working-with-varrays-in-oracle-part-iii-9349"&gt;http://blogs.ittoolbox.com/database/solutions/archives/working-with-varrays-in-oracle-part-iii-9349&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I tried creating an attribute in MicroStrategy which uses this column as its Form but it seems MicroStrategy does not support this data type. Even Freeform Sql failed to generate the sql.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-1972215853438782442?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/1972215853438782442/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=1972215853438782442' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/1972215853438782442'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/1972215853438782442'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/10/creating-oracle-table-varray-data-type.html' title='Creating Oracle Table Varray Data Type Columns'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-3694778881095547934</id><published>2007-08-29T03:30:00.000-07:00</published><updated>2007-08-29T03:40:19.789-07:00</updated><title type='text'>Installing a Loopback Adapter on Windows 2000</title><content type='html'>Dynamic Host Configuration Protocol (DHCP) assigns dynamic IP addresses on a network. Dynamic addressing allows a computer to have a different IP address each time it connects to the network. In some cases, the IP address can change while the computer is still connected.&lt;br /&gt;&lt;br /&gt;You can have a mixture of static and dynamic IP addressing in a DHCP system. In a DHCP setup, the software tracks IP addresses, which simplifies network administration. This lets you add a new computer to the network without having to manually assign that computer a unique IP address. However, before installing Oracle Database onto a computer that uses the DHCP protocol, you need to install a loopback adapter to assign a local IP address to that computer.&lt;br /&gt;&lt;br /&gt;Loopback adapter approach is recommended particularly for laptops (presumably used only for learning purposes!) which connect and disconnect from the real, corporate network. The loopback adapter means that Oracle will function regardless of whether the laptop is connected to the network or not.&lt;em&gt;  &lt;/em&gt;It gives Oracle a static, always-there, point of reference independent of what shenannigans the real NIC gets up to.&lt;br /&gt;&lt;br /&gt;For instructions regarding the Loopback Adapter on Windows 2000 see the instructions from 2.4.5.3 onwards:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://download-west.oracle.com/docs/html/B10130_02/reqs.htm#BABDJJFF"&gt;http://download-west.oracle.com/docs/html/B10130_02/reqs.htm#BABDJJFF&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-3694778881095547934?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/3694778881095547934/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=3694778881095547934' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/3694778881095547934'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/3694778881095547934'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/08/installing-loopback-adapter-on-windows.html' title='Installing a Loopback Adapter on Windows 2000'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-8524193560997471497</id><published>2007-08-24T05:49:00.000-07:00</published><updated>2007-08-24T06:12:21.125-07:00</updated><title type='text'>Transparent Data Encryption (TDE)</title><content type='html'>You can find all the basic stuff about Transparent Data Encryption here:&lt;br /&gt;http://www.oracle.com/technology/oramag/oracle/05-sep/o55security.html&lt;br /&gt;&lt;br /&gt;and here:&lt;br /&gt;http://www.oracle.com/technology/oramag/oracle/05-jan/o15security.html&lt;br /&gt;&lt;br /&gt;We needed to issue the statement in MicroStrategy before running the report:&lt;br /&gt;&lt;strong&gt;alter system set encryption wallet open authenticated by "password";&lt;/strong&gt;  so that the encrypted columns would be displayed in the report.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;" around password are double quotes.&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;However if the statement is issued like this then by selecting the Sql view for the report in MicroStrategy, one can easily see the password and so we needed to hide it inside a procedure.&lt;br /&gt;&lt;br /&gt;I couldnt find any examples of using the alter statement in a procedure and this failed when executed:&lt;br /&gt;&lt;br /&gt;create or replace procedure open_my_wallet is&lt;br /&gt;begin &lt;br /&gt;    execute immediate 'alter system set encryption wallet open authenticated by "password"';    end;&lt;br /&gt;&lt;br /&gt;with privilege errors.&lt;br /&gt;&lt;br /&gt;The reason is that the alter system privilege was given through a role and needs to be granted directly. Alternatively by doing it this way, the privileges are granted directly&lt;br /&gt;&lt;br /&gt;--&lt;br /&gt;create or replace procedure open_wallet &lt;strong&gt;authid current_user&lt;/strong&gt;&lt;br /&gt;is  &lt;br /&gt;begin&lt;br /&gt;  execute immediate 'alter system set encryption wallet open authenticated by "password"'; &lt;br /&gt;end open_wallet;  &lt;br /&gt; /&lt;br /&gt;--&lt;br /&gt;&lt;br /&gt;When a procedure is defined as authid current_user (invoker rights), than all privileges available with granted roles will be available to the procedure&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-8524193560997471497?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/8524193560997471497/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=8524193560997471497' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/8524193560997471497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/8524193560997471497'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/08/transparent-data-encryption-tde.html' title='Transparent Data Encryption (TDE)'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-5702664478976052492</id><published>2007-06-22T04:53:00.000-07:00</published><updated>2007-06-22T06:29:00.393-07:00</updated><title type='text'>Returning clause with insert does not work!</title><content type='html'>On the web there is a lot of material about the new 10g feature returning clause with examples.&lt;br /&gt;However it looks like those who have published these examples have not tested the code and just typed it out.&lt;br /&gt;See : http://orafaq.com/node/34&lt;br /&gt;&lt;br /&gt;Returning clause works fine with Update and Delete.&lt;br /&gt;&lt;br /&gt;Ex:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;declare&lt;br /&gt;       tot_count number;&lt;br /&gt;begin&lt;br /&gt;       delete from pn_1&lt;br /&gt;           RETURNING count(a1) INTO tot_count;&lt;br /&gt; &lt;br /&gt;       dbms_output.put_line(tot_count);&lt;br /&gt;end;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;However with insert&lt;br /&gt;&lt;br /&gt;table pn_1 is created with two columns s1 varchar2(30), a2 number&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;declare&lt;br /&gt;              tot_count number;&lt;br /&gt;begin&lt;br /&gt;&lt;br /&gt;            insert into pn_1&lt;br /&gt;                 select table_name,1&lt;br /&gt;                from user_tables&lt;br /&gt;                RETURNING count(a1) INTO  tot_count;&lt;br /&gt; &lt;br /&gt;       dbms_output.put_line(tot_count);&lt;br /&gt;end;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;it gives syntax  error&lt;br /&gt;ORA-06550: line 5, column 16:&lt;br /&gt;PL/SQL: ORA-00933: SQL command not properly ended&lt;br /&gt;&lt;br /&gt;See Metalink Note:302910.1&lt;br /&gt;&lt;br /&gt;So still the best way to note how many records have been inserted :&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-style:italic;"&gt;&lt;br /&gt;declare&lt;br /&gt; &lt;br /&gt;begin&lt;br /&gt;     insert into pn_1&lt;br /&gt;     select table_name,1 b&lt;br /&gt;     from user_tables;&lt;br /&gt;     --RETURNING sum(b) INTO tot_count;&lt;br /&gt;     dbms_output.put_line(sql%rowcount);&lt;br /&gt;exception&lt;br /&gt;     when others then&lt;br /&gt;     dbms_output.put_line(sqlerrm);&lt;br /&gt;end;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-5702664478976052492?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/5702664478976052492/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=5702664478976052492' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/5702664478976052492'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/5702664478976052492'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/06/returning-clause-with-insert-does-not.html' title='Returning clause with insert does not work!'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-720159746865888927</id><published>2007-06-21T03:09:00.000-07:00</published><updated>2007-06-21T03:11:57.077-07:00</updated><title type='text'>How to Check ORACLE_HOME from the Database</title><content type='html'>First Method:&lt;br /&gt;&lt;br /&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;select&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  NVL&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;substr&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;file_spec&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:maroon;"&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  instr&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;file_spec&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:red;"&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;'\'&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;-&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:maroon;"&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:maroon;"&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;-&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:maroon;"&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  substr&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;file_spec&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:maroon;"&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  instr&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;file_spec&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:red;"&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;'/'&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;-&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:maroon;"&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:maroon;"&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;-&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:maroon;"&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;))&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  folder&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;from&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  dba_libraries&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;where&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt; library_name  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:red;"&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;'DBMS_SUMADV_LIB'&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;2nd Method (Requires priv to run sys.dbms_system) :&lt;/p&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;DECLARE&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  folder  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:red;"&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;VARCHAR2&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:maroon;"&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;100&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;BEGIN&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  sys&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;dbms_system&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;get_env&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:red;"&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;'ORACLE_HOME'&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;  folder&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;  dbms_output.put_line(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;folder&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000f0;"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 0, 240); font-family: 'Courier New';"&gt;END;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;font-size:85%;color:red;"&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&lt;span style="font-size: 10pt; color: black; font-family: 'Courier New';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-720159746865888927?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/720159746865888927/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=720159746865888927' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/720159746865888927'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/720159746865888927'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/06/how-to-check-oraclehome-from-database.html' title='How to Check ORACLE_HOME from the Database'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-977193959267558838</id><published>2007-06-21T02:54:00.000-07:00</published><updated>2007-06-21T02:57:24.140-07:00</updated><title type='text'>Archivelog Mode</title><content type='html'>Just a note of all the things I forget about Archivelog mode&lt;br /&gt;&lt;br /&gt;The easiest way to find out if a database is running in archivelog mode:&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;SQL&gt; select &lt;b&gt;log_mode&lt;/b&gt; from &lt;a href="http://www.adp-gmbh.ch/ora/misc/dynamic_performance_views.html#database"&gt;v$database&lt;/a&gt;;&lt;br /&gt;&lt;br /&gt;LOG_MODE&lt;br /&gt;------------&lt;br /&gt;NOARCHIVELOG&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And for more reference:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.adp-gmbh.ch/ora/admin/backup_recovery/archive_vs_noarchive_log.html"&gt;Archive log related stuff&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-977193959267558838?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/977193959267558838/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=977193959267558838' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/977193959267558838'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/977193959267558838'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/06/archivelog-mode.html' title='Archivelog Mode'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-5363054737257751675</id><published>2007-06-12T06:05:00.000-07:00</published><updated>2007-06-12T06:20:46.284-07:00</updated><title type='text'>dbms_stats</title><content type='html'>There are so many combinations of parameters, how does one decide the most optimum parameters when using dbms_stats?&lt;br /&gt;&lt;br /&gt;One method I found useful is checking the accuracy of num_distinct_rows against time taken for gathering statistics. You want good accurate stats but produced in a short time.&lt;br /&gt;&lt;br /&gt;First compile this Function to automatically and accurately calculate the number of distinct rows:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;create or replace function pn_distinct(p_table in varchar2, p_col in varchar2)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;return number&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;is&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;        q_text varchar2(4000);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;        v_records number;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;begin&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;       &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;           q_text := 'select count(distinct ' p_col ') from 'p_table ;execute immediate(q_text) into v_records; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;           return v_records;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Run the dbms_stat tweaking with the different parameters e.g. to collect stats on all tables in schema that begin with DWH in the example below;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;create or replace procedure dwh_gather_stats&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;as&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;     cursor c1 is&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;     select table_name&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;     from user_tables&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;     where table_name like 'DWH%';&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;begin&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;       For c1rec in c1 loop&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;                    dbms_stats.gather_table_stats(ownname=&gt;'BI_USER',&lt;/span&gt;&lt;span style="font-size:78%;"&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;                                                                                    tabname=&gt;c1rec.table_name,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;                                                                                    estimate_percent=&gt;10,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;                                                                                    method_opt=&gt;'for all columns size auto',&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;                                                                                    cascade=&gt;true);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;        end loop;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;record the time taken with each set of parameters.&lt;br /&gt;&lt;br /&gt;and then run the following query and decide on a trade off between accuracy of the stats and time taken to gather the stats by comparing the num_distinct and actual_distinct columns. You can use this method to compare dbms_stats against analyze as well.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;select p.table_name,p.last_analyzed,t.COLUMN_NAME,t.NUM_DISTINCT,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;            pn_distinct(p.table_name,t.column_name) actual_distinct&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;from user_tab_columns T,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;           user_tables P&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;where p.table_name like 'DWH%'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;   and p.table_name = t.TABLE_NAME&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-5363054737257751675?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/5363054737257751675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=5363054737257751675' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/5363054737257751675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/5363054737257751675'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/06/dbmsstats.html' title='dbms_stats'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-4883411543576382850</id><published>2007-05-10T03:10:00.000-07:00</published><updated>2007-05-10T03:12:00.898-07:00</updated><title type='text'>nls_characterset etc.</title><content type='html'>select *&lt;br /&gt;from sys.props$&lt;br /&gt;&lt;br /&gt;will provide information on all the nls_ settings.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-4883411543576382850?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/4883411543576382850/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=4883411543576382850' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/4883411543576382850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/4883411543576382850'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/05/nlscharacterset-etc.html' title='nls_characterset etc.'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-5838807037887460753</id><published>2007-04-16T08:28:00.000-07:00</published><updated>2007-06-13T01:41:10.386-07:00</updated><title type='text'>Using dbms_datapump for import</title><content type='html'>Doing the import this way can be done straight over a database link so one doesn't even need to do an export.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;create or replace procedure dwh_import&lt;br /&gt;as&lt;br /&gt;         &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;                    ind                         NUMBER;             -- Loop index number&lt;br /&gt;                    jobhandle           NUMBER;             -- Data Pump job handle&lt;br /&gt;                    l_job_name        varchar2(100);       -- Job Name&lt;br /&gt;                    percent_done    NUMBER;                  -- Percentage of job complete&lt;br /&gt;                    job_state               VARCHAR2(30);   -- Keeps track of job state&lt;br /&gt;                    le                               ku$_LogEntry;                 -- work-in-progress and error messages&lt;br /&gt;                    js                               ku$_JobStatus;                -- Job status from get_status&lt;br /&gt;&lt;br /&gt;                    sts                            ku$_Status; -- Status object returned by get_status&lt;br /&gt;&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;                 l_job_name := 'DWHIMPORT'to_char(sysdate,'YYYYMMDDHH24MISS');&lt;br /&gt;                 jobhandle := DBMS_DATAPUMP.OPEN(operation =&gt; 'IMPORT',&lt;br /&gt;                                                                                                  job_mode =&gt; 'TABLE',&lt;br /&gt;                                                                                                 remote_link =&gt; 'APOLLO',&lt;br /&gt;                                                                                                 job_name =&gt; l_job_name,&lt;br /&gt;                                                                                                 version =&gt; 'COMPATIBLE');&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;                 dbms_output.put_line('jobhandle is : 'jobhandle);&lt;br /&gt;&lt;br /&gt;                  DBMS_DATAPUMP.add_file( handle =&gt; jobhandle,&lt;br /&gt;                                                                              filename =&gt; 'DWHIMPORT.log',&lt;br /&gt;                                                                              directory =&gt; 'DATAPUMPX',&lt;br /&gt;                                                                              filetype =&gt; DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE&lt;br /&gt;                                                                             );&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;                  dbms_output.put_line('Import Log file is created..');&lt;br /&gt;&lt;br /&gt;                  DBMS_DATAPUMP.SET_PARALLEL(jobhandle, 1);&lt;br /&gt;                  dbms_output.put_line('parallel set to 1');&lt;br /&gt;&lt;br /&gt;                  DBMS_DATAPUMP.METADATA_REMAP(handle =&gt; jobhandle,&lt;br /&gt;                                                                                                         name =&gt; 'REMAP_SCHEMA',&lt;br /&gt;                                                                                                         old_value =&gt; 'WD_USER',&lt;br /&gt;                                                                                                          value =&gt; 'BI_USER');&lt;br /&gt;                  dbms_output.put_line('metadat_remap');&lt;br /&gt;&lt;br /&gt;                  DBMS_DATAPUMP.SET_PARAMETER(jobhandle,'TABLE_EXISTS_ACTION','REPLACE');&lt;br /&gt;                  dbms_output.put_line('set_parameter');&lt;br /&gt;&lt;br /&gt;-- dbms_datapump.metadata_filter (handle =&gt; my_handle, name =&gt; 'NAME_EXPR',&lt;br /&gt;-- value =&gt; 'LIKE ''DWH_%''', object_type =&gt; 'TABLE');&lt;br /&gt;&lt;br /&gt;                    DBMS_DATAPUMP.metadata_filter( handle =&gt; jobhandle,&lt;br /&gt;                                                                                                name =&gt; 'NAME_EXPR',&lt;br /&gt;                                                                                               value =&gt; 'IN (''DWH_CANVASS'',''DWH_CANVASS_DATE'',''DWH_CHANNEL'',&lt;br /&gt;''DWH_CUSTOMER'',''DWH_CYCLE_DATE'', ''DWH_DATE'',&lt;br /&gt;''DWH_DOS_APPOINTMENTS'',''DWH_DOS_SALESREP_TARGET'',&lt;br /&gt;''DWH_DOS_STATE_OF_PLAY'',''DWH_DOS_TEAM'',''DWH_GG_ICANVASS'',&lt;br /&gt;''DWH_GG_WD_CHANNEL'',''DWH_GG_WD_PRODUCTS'',''DWH_GP_WD_CHANNEL'',&lt;br /&gt;''DWH_GP_WD_PRODUCTS'',''DWH_MANDAYS_ACTUALS'',&lt;br /&gt;''DWH_MANDAYS_PLANNED'',''DWH_PA_WD_CHANNEL'',''DWH_PA_WD_PRODUCTS'',&lt;br /&gt;''DWH_PM_WD_CHANNEL'',''DWH_PM_WD_PRODUCTS'',''DWH_PRODUCT'',&lt;br /&gt;''DWH_REP'',''DWH_SALES'',''DWH_SALES_STATUS'',''DWH_TARGET'',&lt;br /&gt;''DWH_UNIT'',''DWH_WD_CANVASS_GROUPS'',''DWH_WD_CHANNEL'',&lt;br /&gt;''DWH_WD_CHANNEL_GRP'',''DWH_WD_DAYOFF'',''DWH_WD_FINANCE_MONTH'',&lt;br /&gt;''DWH_WD_PRODUCT'',''DWH_REFRESH_DATES'',''DWH_MTG_TARGET'',''DWH_DAY_TARGET_ALL'',&lt;br /&gt;''DWH_DAY_TARGET_SALES'',''DWH_DAY_TARGET_CANV'')');&lt;br /&gt;dbms_output.put_line('Name Export');&lt;br /&gt;&lt;br /&gt;dbms_datapump.metadata_remap(handle =&gt; jobhandle,&lt;br /&gt;                                                                         name =&gt; 'REMAP_TABLESPACE',&lt;br /&gt;                                                                         old_value =&gt; 'DWH_TAB_SMALL',&lt;br /&gt;                                                                         value =&gt; 'BI_USER_TS');&lt;br /&gt;&lt;br /&gt;dbms_datapump.metadata_remap(handle =&gt; jobhandle,&lt;br /&gt;                                                                          name =&gt; 'REMAP_TABLESPACE',&lt;br /&gt;                                                                         old_value =&gt; 'DWH_TAB_LARGE',&lt;br /&gt;                                                                         value =&gt; 'BI_USER_TS');&lt;br /&gt;&lt;br /&gt;dbms_datapump.metadata_remap(handle =&gt; jobhandle,&lt;br /&gt;                                                                          name =&gt; 'REMAP_TABLESPACE',&lt;br /&gt;                                                                          old_value =&gt; 'DWH_IND_LARGE',&lt;br /&gt;                                                                          value =&gt; 'USERS');&lt;br /&gt;&lt;br /&gt;dbms_datapump.metadata_remap(handle =&gt; jobhandle,&lt;br /&gt;                                                                          name =&gt; 'REMAP_TABLESPACE',&lt;br /&gt;                                                                         old_value =&gt; 'DWH_IND_SMALL',&lt;br /&gt;                                                                        value =&gt; 'USERS');&lt;br /&gt;&lt;br /&gt;        DBMS_DATAPUMP.SET_PARAMETER(jobhandle,'ESTIMATE','STATISTICS');&lt;br /&gt;       dbms_output.put_line('Estimate ');&lt;br /&gt;&lt;br /&gt;        DBMS_DATAPUMP.START_JOB(jobhandle);&lt;br /&gt;        dbms_output.put_line('Job Started');&lt;br /&gt;&lt;br /&gt;        percent_done := 0;&lt;br /&gt;        job_state := 'UNDEFINED';&lt;br /&gt;&lt;br /&gt;         WHILE  (job_state != 'COMPLETED') and (job_state != 'STOPPED')  LOOP&lt;br /&gt;                  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;                  DBMS_DATAPUMP.get_status(jobhandle,&lt;br /&gt;                                                                                  DBMS_DATAPUMP.ku$_status_job_error +&lt;br /&gt;                                                                                 DBMS_DATAPUMP.ku$_status_job_status +&lt;br /&gt;                                                                                 DBMS_DATAPUMP.ku$_status_wip,-1,job_state,sts);&lt;br /&gt;                  js := sts.job_status;&lt;br /&gt;&lt;br /&gt;                IF  js.percent_done != percent_done THEN&lt;br /&gt;                      DBMS_OUTPUT.PUT_LINE('*** Job percent done = ' to_char(js.percent_done));&lt;br /&gt;                     percent_done := js.percent_done;&lt;br /&gt;               END IF;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;               IF (bitand(sts.mask,dbms_datapump.ku$_status_wip) != 0) THEN&lt;br /&gt;                       le := sts.wip;&lt;br /&gt;              ELSE&lt;br /&gt;                 IF (bitand(sts.mask,dbms_datapump.ku$_status_job_error) != 0) THEN&lt;br /&gt;                         le := sts.error;&lt;br /&gt;                  ELSE&lt;br /&gt;                     le := null;&lt;br /&gt;                 END IF;&lt;br /&gt;             END IF;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;           IF  le IS NOT NULL THEN &lt;br /&gt;                    ind := le.FIRST;&lt;br /&gt;               WHILE  ind IS NOT NULL LOOP                    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;                     DBMS_OUTPUT.PUT_LINE(le(ind).LogText);&lt;br /&gt;                     ind := le.NEXT(ind);                &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;               END LOOP;&lt;br /&gt;           END IF; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;         &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;        END LOOP;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;             DBMS_OUTPUT.PUT_LINE('Job has completed');&lt;br /&gt;             DBMS_OUTPUT.PUT_LINE('Final job state = ' job_state);&lt;br /&gt;             DBMS_DATAPUMP.DETACH(jobhandle);&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;END;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-5838807037887460753?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/5838807037887460753/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=5838807037887460753' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/5838807037887460753'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/5838807037887460753'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/04/using-dbmsdatapump-for-import.html' title='Using dbms_datapump for import'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-1884411266602675300</id><published>2007-04-16T08:16:00.000-07:00</published><updated>2007-06-13T01:18:18.457-07:00</updated><title type='text'>dbms_datapump for Export</title><content type='html'>Example of dbms_datapump for Export in a procedure that can be automated from dbms_jobsubmit:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;CREATE OR REPLACE PROCEDURE "DWH_EXPORT"("P_JOB_NAME" OUT NOCOPY VARCHAR2)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt; IS&lt;br /&gt;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;             l_dp_handle NUMBER;&lt;br /&gt;             l_job_name varchar2(100);&lt;br /&gt;             l_file_name varchar2(100);&lt;br /&gt;&lt;br /&gt;             job_state varchar2(30);&lt;br /&gt;            status ku$_Status1010;&lt;br /&gt;&lt;br /&gt;begin&lt;br /&gt;&lt;br /&gt;                   l_job_name := 'DWH'to_char(sysdate,'YYYYMMDDHH24MISS');&lt;br /&gt;                   l_file_name := 'DWH.dmp';&lt;br /&gt;&lt;br /&gt;                  utl_file.fremove('DATAPUMPX',l_file_name);&lt;br /&gt;&lt;br /&gt;                  l_dp_handle := DBMS_DATAPUMP.open( operation =&gt; 'EXPORT',&lt;br /&gt;                                                                                                                                    job_mode =&gt; 'TABLE',&lt;br /&gt;                                                                                                                                    remote_link =&gt; NULL,&lt;br /&gt;                                                                                                                                    job_name =&gt; l_job_name,&lt;br /&gt;                                                                                                                                    version =&gt; 'LATEST'&lt;br /&gt;                                                                                                     );&lt;br /&gt;&lt;br /&gt;                     DBMS_DATAPUMP.add_file( handle =&gt; l_dp_handle,&lt;br /&gt;                                                                                filename =&gt; l_file_name,&lt;br /&gt;                                                                                directory =&gt; 'DATAPUMPX',&lt;br /&gt;                                                                                 filetype =&gt; DBMS_DATAPUMP.KU$_FILE_TYPE_DUMP_FILE&lt;br /&gt;                                                                                );&lt;br /&gt;&lt;br /&gt;                      DBMS_DATAPUMP.add_file( handle =&gt; l_dp_handle,&lt;br /&gt;                                                                                  filename =&gt; 'DWH.log',&lt;br /&gt;                                                                                 directory =&gt; 'DATAPUMPX',&lt;br /&gt;                                                                                 filetype =&gt; DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE&lt;br /&gt;                                                                                  );&lt;br /&gt;&lt;br /&gt;                     DBMS_DATAPUMP.metadata_filter( handle =&gt; l_dp_handle,&lt;br /&gt;                                                                                                name =&gt; 'SCHEMA_EXPR',&lt;br /&gt;                                                                                                value =&gt; 'IN (''WD_USER'')'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;                                                                                             );&lt;br /&gt;&lt;br /&gt;                     DBMS_DATAPUMP.metadata_filter( handle =&gt; l_dp_handle,&lt;br /&gt;                                                                                                 name =&gt; 'NAME_EXPR',&lt;br /&gt;                                                                                                value =&gt; 'IN   (''DWH_CANVASS'',''DWH_CANVASS_DATE'',''DWH_CHANNEL'',&lt;br /&gt;''DWH_CUSTOMER'',''DWH_CYCLE_DATE'', ''DWH_DATE'',&lt;br /&gt;''DWH_DOS_APPOINTMENTS'',''DWH_DOS_SALESREP_TARGET'',&lt;br /&gt;''DWH_DOS_STATE_OF_PLAY'',''DWH_DOS_TEAM'',''DWH_GG_ICANVASS'',&lt;br /&gt;''DWH_GG_WD_CHANNEL'',''DWH_GG_WD_PRODUCTS'',''DWH_GP_WD_CHANNEL'',&lt;br /&gt;''DWH_GP_WD_PRODUCTS'',''DWH_MANDAYS_ACTUALS'',&lt;br /&gt;''DWH_MANDAYS_PLANNED'',''DWH_PA_WD_CHANNEL'',''DWH_PA_WD_PRODUCTS'',&lt;br /&gt;''DWH_PM_WD_CHANNEL'',''DWH_PM_WD_PRODUCTS'',''DWH_PRODUCT'',&lt;br /&gt;''DWH_REP'',''DWH_SALES'',''DWH_SALES_STATUS'',''DWH_TARGET'',&lt;br /&gt;''DWH_UNIT'',''DWH_WD_CANVASS_GROUPS'',''DWH_WD_CHANNEL'',&lt;br /&gt;''DWH_WD_CHANNEL_GRP'',''DWH_WD_DAYOFF'',''DWH_WD_FINANCE_MONTH'',&lt;br /&gt;''DWH_WD_PRODUCT'',''DWH_REFRESH_DATES'',''DWH_MTG_TARGET'',''DWH_DAY_TARGET_ALL'',&lt;br /&gt;''DWH_DAY_TARGET_SALES'',''DWH_DAY_TARGET_CANV'')');&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                               DBMS_DATAPUMP.start_job(l_dp_handle);&lt;br /&gt;                              p_job_name := l_job_name;&lt;br /&gt;&lt;br /&gt;          job_state := 'UNDEFINED';&lt;br /&gt;          &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;           WHILE  (job_state != 'COMPLETED') and (job_state != 'STOPPED')   LOOP&lt;br /&gt;                      &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;                       DBMS_DATAPUMP.GET_STATUS(l_dp_handle,&lt;br /&gt;                       dbms_datapump.KU$_STATUS_WIP,&lt;br /&gt;                       -1,&lt;br /&gt;                       job_state,&lt;br /&gt;                      status); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;          END LOOP;&lt;br /&gt;&lt;br /&gt;           DBMS_DATAPUMP.detach(l_dp_handle);&lt;br /&gt;&lt;br /&gt;EXCEPTION&lt;br /&gt;&lt;br /&gt;              WHEN OTHERS THEN&lt;br /&gt;                      dbms_output.put_line('Error:' sqlerrm ' for Job:' l_dp_handle);&lt;br /&gt;                       RAISE_APPLICATION_ERROR (-20100,'Export Failed - 'sqlerrm);&lt;br /&gt;&lt;br /&gt;END;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-1884411266602675300?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/1884411266602675300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=1884411266602675300' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/1884411266602675300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/1884411266602675300'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/04/dbmsdatapump-for-export.html' title='dbms_datapump for Export'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-2663118958163426027</id><published>2007-04-16T08:10:00.000-07:00</published><updated>2007-04-16T08:15:28.757-07:00</updated><title type='text'>ORA-31626</title><content type='html'>I was getting the above error when I was trying to do this:&lt;br /&gt;&lt;br /&gt;jobhandle := DBMS_DATAPUMP.OPEN(operation =&gt; 'IMPORT',&lt;br /&gt;                                                                         job_mode =&gt; 'TABLE',&lt;br /&gt;                                                                         remote_link =&gt; 'db_link',&lt;br /&gt;                                                                        job_name =&gt;'DWH_IMPORT');&lt;br /&gt;&lt;br /&gt;Did a lot of searching for priviliges and how they were granted, whether through a role or directly etc. At the end it boiled down to the job_name being the same as the procedure name. Changed the job name and the above then worked.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-2663118958163426027?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/2663118958163426027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=2663118958163426027' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2663118958163426027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2663118958163426027'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/04/ora-31626.html' title='ORA-31626'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-208538973816633873</id><published>2007-04-13T02:27:00.000-07:00</published><updated>2007-04-20T06:11:19.442-07:00</updated><title type='text'>OWB Process Flow Not Deploying</title><content type='html'>If the Process Flow is not deploying and its due to a run away process still executing, find out what the processes are by running this query&lt;br /&gt;&lt;br /&gt;select t.*&lt;br /&gt;from wb_rt_audit_deployments t&lt;br /&gt;where audit_status &lt;&gt; wb_rt_constants.DEPLOYMENT_STATUS_COMPLETE&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-208538973816633873?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/208538973816633873/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=208538973816633873' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/208538973816633873'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/208538973816633873'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/04/owb-process-flow-not-deploying.html' title='OWB Process Flow Not Deploying'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-2169831153540359827</id><published>2007-03-08T05:29:00.000-08:00</published><updated>2007-03-08T05:35:15.869-08:00</updated><title type='text'>Datapump on Windows Platform</title><content type='html'>I was trying to do an impdp on a windows platform but I got the follwoing error:&lt;br /&gt;&lt;br /&gt;ORA-39002: invalid operation&lt;br /&gt;ORA-39070: Unable to open the log file.&lt;br /&gt;ORA-29283: invalid file operation&lt;br /&gt;ORA-06512: at "SYS.UTL_FILE", line 475&lt;br /&gt;ORA-29283: invalid file operation&lt;br /&gt;&lt;br /&gt;The obvious answer seems to be the Oracle Directory is not created or is missing read/write priviliges. However this was not the case. as teh following query showed:&lt;br /&gt;&lt;br /&gt;SELECT d.owner,privilege, directory_name&lt;br /&gt;FROM user_tab_privs t&lt;br /&gt;          , all_directories d&lt;br /&gt;WHERE t.table_name(+)=d.directory_name&lt;br /&gt;ORDER BY 3,2&lt;br /&gt;&lt;br /&gt;The problem is that the directory was created using a mapped network drive which was mapped after Oracle was started. Oracle therefore could not read teh directory.&lt;br /&gt;See:&lt;br /&gt;Metalink :  &lt;a href="https://metalink.oracle.com/help/usaeng/Search/search.html#file"&gt;Doc ID&lt;/a&gt;:  Note:221849.1&lt;br /&gt;&lt;br /&gt;Symptom(s)&lt;br /&gt;ORA-29283 Invalid file operation when accessing file on a mappeddrive using utl_file package&lt;br /&gt;&lt;br /&gt;Cause&lt;br /&gt;The reason for this error is because Oracle service isstarted using system account(default) which doesnt haveprivilege in the mapped folder.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-2169831153540359827?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/2169831153540359827/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=2169831153540359827' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2169831153540359827'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2169831153540359827'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/03/datapump-on-windows-platform.html' title='Datapump on Windows Platform'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-1150762115585831006</id><published>2007-03-02T07:31:00.000-08:00</published><updated>2007-03-07T02:57:43.663-08:00</updated><title type='text'>OWB PARIS Problems</title><content type='html'>So far these are some of the OWB PARIS problems/bugs I have come across since started using it.  This problems are happening when exports are made on a 64 bit windows machine into a 32 bits windows machine:&lt;br /&gt;&lt;br /&gt;Problem:&lt;br /&gt;- You change a process flow and deploy it, but it does not behave as the diagram shows.&lt;br /&gt;Solution:&lt;br /&gt;- Redo the entire process flow from scratch. A clue to the fact that the process flow will not behave in the same way as the diagram shows is to check the outgoing flows from a node. If the are the same numbers in &lt;&gt; it means there is a problem. Something that OWB should validate itself but thats the way OWB PARIS is at the moment.&lt;br /&gt;&lt;br /&gt;Note: Work Flow Manager Client can show the errors on the process flow.&lt;br /&gt;&lt;br /&gt;Problem:&lt;br /&gt;- The columns to merge on are not set properly when mappings are imported from another OWB installation.&lt;br /&gt;Solution:&lt;br /&gt;- Reset the merge columns correctly again.&lt;br /&gt;or  Create the package in production only.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-1150762115585831006?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/1150762115585831006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=1150762115585831006' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/1150762115585831006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/1150762115585831006'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/03/owb-paris-problems.html' title='OWB PARIS Problems'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-555352403610330515</id><published>2007-02-27T01:48:00.000-08:00</published><updated>2007-03-02T07:27:07.211-08:00</updated><title type='text'>Using Partition By in a Lag</title><content type='html'>&lt;div align="left"&gt;I had to "unaccumulate" figures in a table. A colleague suggested using the Lag function. Most of the Analytic Lag function examples show the order by clause only, but if the calculations using Lag function are related to specific group of records within a table, then we need the partition by as well. Here is the syntax of how to use partition by as well as order by in a Lag function:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;select t.target_type,t.version,t.unit_code,t.canvass,t.product_descr,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;t.channel_name,t.aggr_level,t.cycle,t.yearmonth,t.charge_out, &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;t.charge_out - &lt;span style="color:#3366ff;"&gt;(&lt;strong&gt;lag&lt;/strong&gt;(charge_out,1,0)&lt;strong&gt; over&lt;/strong&gt; (&lt;strong&gt;partition by&lt;/strong&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color:#3366ff;"&gt;&lt;span style="font-size:78%;"&gt;t.target_type,t.version,t.unit_code,t.canvass,t.product_descr,&lt;br /&gt;t.channel_name,t.aggr_level,t.cycle&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;strong&gt;order by&lt;/strong&gt; &lt;/span&gt;&lt;span style="font-size:78%;"&gt;t.target_type,t.version,t.unit_code,t.canvass,t.product_descr,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="color:#3366ff;"&gt;t.channel_name,t.aggr_level,t.cycle,to_date(t.yearmonth,'mon-yy') ))&lt;/span&gt; m_charge_out&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="font-size:85%;"&gt;from dwh_target T&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="font-size:85%;"&gt;order by &lt;/span&gt;&lt;span style="font-size:78%;"&gt;t.target_type,t.version,t.unit_code,t.canvass,t.product_descr,t.channel_name,t.aggr_level,t.cycle,to_date(t.yearmonth,'mon-yy') &lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;See also:&lt;/div&gt;&lt;div align="left"&gt;&lt;a href="http://orafaq.com/node/55"&gt;http://orafaq.com/node/55&lt;/a&gt;&lt;/div&gt;&lt;div align="left"&gt; &lt;/div&gt;&lt;div align="left"&gt;If you use this in OWB exprssions [Paris Version], make sure its all on one line, otherwise it will compile wrongly. &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-555352403610330515?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/555352403610330515/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=555352403610330515' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/555352403610330515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/555352403610330515'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/02/using-partition-by-in-lag.html' title='Using Partition By in a Lag'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-1357426524016370961</id><published>2007-01-12T10:04:00.000-08:00</published><updated>2007-01-12T10:35:40.641-08:00</updated><title type='text'>Identifying Sql Statements that Could use Bind Parameters</title><content type='html'>This function will identify statements that are the same if they used bind variables:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;create or replace function remove_constants( p_query in varchar2 )&lt;br /&gt;return varchar2&lt;br /&gt;as l_query long;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;l_char varchar2(1);&lt;br /&gt;l_in_quotes boolean default FALSE;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;BEGIN&lt;br /&gt;for i in 1 .. length( p_query )&lt;br /&gt;loop l_char := substr(p_query,i,1);&lt;br /&gt;if ( l_char = '''' and l_in_quotes ) then l_in_quotes := FALSE;&lt;br /&gt;elsif ( l_char = '''' and NOT l_in_quotes ) then l_in_quotes := TRUE;&lt;br /&gt;l_query := l_query '''#';&lt;br /&gt;end if;&lt;br /&gt;&lt;br /&gt;if ( NOT l_in_quotes ) then&lt;br /&gt;l_query := l_query l_char;&lt;br /&gt;end if;&lt;br /&gt;end loop;&lt;br /&gt;&lt;br /&gt;l_query := translate( l_query, '0123456789', '@@@@@@@@@@' );&lt;br /&gt;&lt;br /&gt;for i in 0 .. 8 loop&lt;br /&gt;l_query := replace( l_query, lpad('@',10-i,'@'), '@' );&lt;br /&gt;l_query := replace( l_query, lpad(' ',10-i,' '), ' ' );&lt;br /&gt;end loop;&lt;br /&gt;return upper(l_query);&lt;br /&gt;END;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;Now following this example can show how the above function can be used:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;create global temporary table sql_area_tmp&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;on commit preserve rows&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;as&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;select sql_text,sql_text sql_text_two_constants&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;from v$sqlarea&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;where 1=0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="fullpost"&gt;&lt;br /&gt;This is an sql example that does not use bind parameters and so essentially the same statement is read and parsed repeatedly:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;DECLARE&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;cursor c1 is&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;select object_name&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;from dba_objects;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;l_object dba_objects.object_name%type;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;BEGIN&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for c1rec in c1 loop&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;execute immediate 'insert into pn_temp values('''''c1rec.object_name''''')';&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end loop;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;END;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;Scripts below will show how this statement can be identified as an Sql statement that should be re-examined for re-writing with bind parameters:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;insert into sql_area_tmp(sql_text)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;select sql_text&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;from v$sqlarea&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;update sql_area_tmp&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;set sql_text_two_constants = remove_constants(sql_text)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;select sql_text_two_constants,count(*)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;from sql_area_tmp&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;group by sql_text_two_constants&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;order by 2 desc&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Sql statemnets that should be re-examined will appear at the top with a high count.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-1357426524016370961?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/1357426524016370961/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=1357426524016370961' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/1357426524016370961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/1357426524016370961'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/identifying-sql-statements-that-could.html' title='Identifying Sql Statements that Could use Bind Parameters'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-2534763468273395382</id><published>2007-01-10T04:03:00.000-08:00</published><updated>2007-01-10T04:32:50.632-08:00</updated><title type='text'>Top N Query</title><content type='html'>I remember back in the days of Oracle V6, I was asked a question in an interview to write a query in Sql - not using Pl/Sql - to show the top 5 Salaries from the EMP table. Ever since then I have been interested in queries that answer this.&lt;br /&gt;&lt;br /&gt;Using the analytic function dense_rank as pointed out by Tom Kyte in this month's Oracle magazine, is the best I have seen so far.&lt;br /&gt;&lt;br /&gt;select *&lt;br /&gt;from (&lt;br /&gt;      select deptno,ename,sal,dense_rank() over (partition by deptno order by sal desc) Salrnk&lt;br /&gt;      from emp)&lt;br /&gt;where SalRnk &lt;=3&lt;br /&gt;order by deptno,sal desc&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-2534763468273395382?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/2534763468273395382/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=2534763468273395382' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2534763468273395382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2534763468273395382'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/top-n-query.html' title='Top N Query'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-2702140333344927592</id><published>2007-01-04T15:42:00.002-08:00</published><updated>2007-01-04T15:43:04.442-08:00</updated><title type='text'>IN A OWB MAPPING GENERATED JOIN IS CORRUPTED</title><content type='html'>This is not the sort of thing one would expect to be a bug but sadly it is. It seems to happen with complex joins when you add in new attributes. And the only way round it is to do the join again. &lt;br /&gt;&lt;br /&gt;See bug no. 4914839 in Metalink. &lt;br /&gt;Problem ========== Customer has a mapping which has many operators including a join operator. In the output group of join operator output attributes are linked to unrelated items from the input group and hence the final result generated is inserting incorrect values into columns. &lt;br /&gt;&lt;br /&gt;03/10/06 07:02 am *** Another note from another developer: ==================================== &lt;br /&gt;Back in Bombay, we didn't have the joiner input/output matching properties at all, and no "doPropertyUpgrade" method. So this is probably related to an older joiner metadata corruption bug, not our recent paris bug. I recall that the old bug may be triggered by some combination of adding/removing attributes or groups on the joiner in an older version (pre-Bombay), then upgrading the repository. . At this point, I think You are right that the only way to fix it is to recreate the joiner.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-2702140333344927592?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/2702140333344927592/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=2702140333344927592' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2702140333344927592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2702140333344927592'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/in-owb-mapping-generated-join-is.html' title='IN A OWB MAPPING GENERATED JOIN IS CORRUPTED'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-8011519139992111471</id><published>2007-01-04T15:42:00.001-08:00</published><updated>2007-02-04T07:50:18.299-08:00</updated><title type='text'>Creating SCD2 and SCD1 Mappings Using OWB</title><content type='html'>I came across this article on the Oracle Technology site on how to address &lt;a href="http://www.oracle.com/technology/oramag/webcolumns/2003/techarticles/buschonowb.html"&gt;slowly changing dimensions in OWB&lt;/a&gt;, which is all well and good.&lt;br /&gt;&lt;br /&gt;Personally however my favourite solution is to use the attribute properties and create a merge statement when target is being populated.&lt;br /&gt;See:&lt;br /&gt;&lt;br /&gt;The target table's operator properties should be set to update/insert.&lt;br /&gt;The surrogate key populated from a sequence should have its attribute properties set to:&lt;br /&gt;Load Column When Inserting Row - Yes&lt;br /&gt;Load Column When Updating Row - No&lt;br /&gt;Match Column When Updating Row - No&lt;br /&gt;Update Operation - =&lt;br /&gt;&lt;br /&gt;Columns which have been decided to be SCD2 types, should have their attribute properties set to:&lt;br /&gt;Load Column When Inserting Row - Yes&lt;br /&gt;Load Column When Updating Row - No&lt;br /&gt;Match Column When Updating Row - Yes&lt;br /&gt;Update Operation - =&lt;br /&gt;Match Column When Deleting - No&lt;br /&gt;&lt;br /&gt;and SCD1 Types should be set to:&lt;br /&gt;Load Column When Inserting Row - Yes&lt;br /&gt;Load Column When Updating Row - Yes&lt;br /&gt;Match Column When Updating Row - No&lt;br /&gt;Update Operation - =&lt;br /&gt;Match Column When Deleting - No&lt;br /&gt;&lt;br /&gt;If there are any further updates like setting the flag to identify the most current record etc. the target table should be joined with the source in another part of the same mapping with a join condition which will identify the records to be updated in a similar fashion to below:&lt;br /&gt;&lt;br /&gt;join operator property:&lt;br /&gt;&lt;br /&gt;src.natural_key = trg.natural_key and&lt;br /&gt;trg.current_flag = 'Y'&lt;br /&gt;(src.scd2type_col1 != trg.scd2type_col1 or&lt;br /&gt;src.scd2type_col2 != trg.scd2type_col2)&lt;br /&gt;......&lt;br /&gt;&lt;br /&gt;i.e this will identify all the records that were current but are no longer current in accordance with the latest source.&lt;br /&gt;&lt;br /&gt;Finally join the above join results to the target table with operator property set to UPDATE.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-8011519139992111471?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/8011519139992111471/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=8011519139992111471' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/8011519139992111471'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/8011519139992111471'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/creating-scd2-and-scd1-mappings-using.html' title='Creating SCD2 and SCD1 Mappings Using OWB'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-8677994432741094000</id><published>2007-01-04T15:41:00.001-08:00</published><updated>2007-01-04T15:41:37.607-08:00</updated><title type='text'>OWB Error</title><content type='html'>I was trying to load a flat file into an external table in Oracle Warehouse Builder and I got a strange error. OWB validated both the flat file and the external table, it generated the script, I deployed it and the table was created ok too. However when I tried to do a select from the external table my sql session was terminated. &lt;br /&gt;There was also no .log or .bad file produced which made the problem investigation even harder. &lt;br /&gt;&lt;br /&gt;The flat file had 56 columns and at first I thought there may be some limit to the number of columns. The problem however turned out to be a mispelling with the date format. I had accidentally typed hh24:mis:ss format for a date field. &lt;br /&gt;&lt;br /&gt;Bit disappointed that OWB did not catch this out in the validation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-8677994432741094000?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/8677994432741094000/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=8677994432741094000' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/8677994432741094000'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/8677994432741094000'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/owb-error.html' title='OWB Error'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-2795702041929709629</id><published>2007-01-04T15:40:00.002-08:00</published><updated>2007-01-04T15:41:04.100-08:00</updated><title type='text'>ORA-12514 Error</title><content type='html'>Couldn't connect to a client database via pl/sql developer today and kept getting ora-12514 error. I couldn't see why though. There was only one tnsnames.ora file in the correct place and all the information was correct. pl/sql developer automatically picked up the service name too, which proved it was reading the tnsnames.ora file from the correct place. &lt;br /&gt;&lt;br /&gt;What was confusing me more was that the OWB connected to the database without a problem. Of course OWB does not use TCP/IP but it proved the database was up and running. &lt;br /&gt;&lt;br /&gt;Tried using sqlplus from the command prompt and I got the same error again. It turned out the problem was a typo error not in tnsnames.ora but in the sqlnet.ora. So something to remember if I get ora-12514 error again.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-2795702041929709629?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/2795702041929709629/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=2795702041929709629' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2795702041929709629'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2795702041929709629'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/ora-12514-error.html' title='ORA-12514 Error'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-2273731918515630600</id><published>2007-01-04T15:40:00.001-08:00</published><updated>2007-01-04T15:40:34.257-08:00</updated><title type='text'>Rewrite_Table</title><content type='html'>If your query is not using the Materialized View, use the /*+ rewrite(mvname) */ hint first to make sure that the query can be redirecte dto use the MV. Usually if the MV is correctly written to correspond to the query but it is still not used, is because the optimizer obtains a lower cost by not using the Materialized views. Think of indexing the MV or increasing its parallel execution if possible: &lt;br /&gt;&lt;br /&gt;ALTER MATERIALIZED VIEW mv_name PARALLEL n &lt;br /&gt;&lt;br /&gt;If using the rewrite hint shows that the cost of using the MV is lower but the optimizer still chooses not to use the MV, then you can use the dbms_mview.explain_rewrite package to obtain more info: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;BEGIN &lt;br /&gt;&lt;br /&gt;DBMS_MVIEW.EXPLAIN_REWRITE('Query','mv_name','s_id'); &lt;br /&gt;&lt;br /&gt;END; &lt;br /&gt;&lt;br /&gt;Then &lt;br /&gt;SELECT * FROM rewrite_table where statement_id = 's_id' &lt;br /&gt;&lt;br /&gt;and hopefully that will tell you the reason.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-2273731918515630600?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/2273731918515630600/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=2273731918515630600' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2273731918515630600'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2273731918515630600'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/rewritetable.html' title='Rewrite_Table'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-7431149239618742199</id><published>2007-01-04T15:39:00.003-08:00</published><updated>2007-01-04T15:39:55.372-08:00</updated><title type='text'>Materialized View</title><content type='html'>Here is a query which takes a long time because of the join: &lt;br /&gt;&lt;br /&gt;SELECT a13.PT_CODE PT_CODE, &lt;br /&gt;a16.PT_NAME PT_NAME, &lt;br /&gt;a15.SCIENTIFICGROUPCODE SCIENTIFICGROUPCODE, &lt;br /&gt;a15.SCIETNIFICGROUPNAME SCIENTIFICGROUPNAME, &lt;br /&gt;count(distinct a11.SAFETYREPORTKEY) WJXBFS1 &lt;br /&gt;from DWH.F_SAFETYREPORT a11 &lt;br /&gt;join DWH.F_ADVERSEREACTION a12 &lt;br /&gt;on (a11.SAFETYREPORTKEY = a12.SAFETYREPORTKEY) &lt;br /&gt;join DWH.M_LLT_PT_61_CUR1_VW a13 &lt;br /&gt;on (a12.REACTIONMEDDRALLT = a13.LLT_CODE) &lt;br /&gt;join DWH.C_INDEX_SCIENTIFIC a14 &lt;br /&gt;on (a12.PRODUCTINDEXCODE = a14.PRODUCTINDEXCODE) &lt;br /&gt;join DWH.H_SCIENTIFICPRODUCT a15 &lt;br /&gt;on (a14.SCIENTIFICPRESENTATIONID = a15.SCIENTIFICPRESENTATIONID) &lt;br /&gt;join DWH.H_MD61_PSFGY_VW a16 &lt;br /&gt;on (a13.PT_CODE = a16.PT_CODE) &lt;br /&gt;where (a11.CASEVALIDFROM &lt;= To_Date('09-06-2006', 'dd-mm-yyyy') and a11.CASEVALIDTO &gt; To_Date('09-06-2006', 'dd-mm-yyyy') &lt;br /&gt;and a11.CLASSIFICATION not in (4) &lt;br /&gt;and a15.SCIENTIFICPRODUCTID in (20923)) &lt;br /&gt;group by a13.PT_CODE, &lt;br /&gt;a16.PT_NAME, &lt;br /&gt;a15.SCIENTIFICGROUPCODE, &lt;br /&gt;a15.SCIETNIFICGROUPNAME &lt;br /&gt;&lt;br /&gt;To use Materialized View, this is how we should create a Materialized View: &lt;br /&gt;&lt;br /&gt;CREATE MATERIALIZED VIEW mv_scigroup_pt &lt;br /&gt;build immediate &lt;br /&gt;refresh on DEMAND &lt;br /&gt;enable query rewrite &lt;br /&gt;AS &lt;br /&gt;select a13.PT_CODE PT_CODE, &lt;br /&gt;a16.PT_NAME PT_NAME, &lt;br /&gt;a15.SCIENTIFICGROUPCODE SCIENTIFICGROUPCODE, &lt;br /&gt;a15.SCIETNIFICGROUPNAME SCIENTIFICGROUPNAME, &lt;br /&gt;a11.casevalidfrom, &lt;br /&gt;a11.casevalidto, &lt;br /&gt;a15.scientificproductid, &lt;br /&gt;a11.safetyreportkey &lt;br /&gt;from DWH.F_SAFETYREPORT a11 &lt;br /&gt;join DWH.F_ADVERSEREACTION a12 &lt;br /&gt;on (a11.SAFETYREPORTKEY = a12.SAFETYREPORTKEY) &lt;br /&gt;join DWH.M_LLT_PT_61_CUR1_VW a13 &lt;br /&gt;on (a12.REACTIONMEDDRALLT = a13.LLT_CODE) &lt;br /&gt;join DWH.C_INDEX_SCIENTIFIC a14 &lt;br /&gt;on (a12.PRODUCTINDEXCODE = a14.PRODUCTINDEXCODE) &lt;br /&gt;join DWH.H_SCIENTIFICPRODUCT a15 &lt;br /&gt;on (a14.SCIENTIFICPRESENTATIONID = a15.SCIENTIFICPRESENTATIONID) &lt;br /&gt;join DWH.H_MD61_PSFGY_VW a16 &lt;br /&gt;on (a13.PT_CODE = a16.PT_CODE) &lt;br /&gt;where a11.CLASSIFICATION not in (4) &lt;br /&gt;&lt;br /&gt;In this case the where clause is common to all queries and the other where clauses are removed and the columns used in the select statement. Once the Materialized view is created, if you run an explain plan for the query, it should use the Materialized View instead of the underlying tables. &lt;br /&gt;&lt;br /&gt;You can drop the Materialized View if you dont want the plan to use it or you can do this: &lt;br /&gt;ALTER MATERIALIZED VIEW mv_scigroup_pt DISABLE QUERY REWRITE &lt;br /&gt;&lt;br /&gt;to analyze the MV, you treat it as a table: &lt;br /&gt;&lt;br /&gt;Analyze table mv_scigroup_pt compute statistics; &lt;br /&gt;&lt;br /&gt;To put indexes on the Materialized View, again treat it as an index on an ordinary table: &lt;br /&gt;CREATE INDEX mv_srid_idx ON mv_scigroup_pt(safetyreportkey) &lt;br /&gt;&lt;br /&gt;and analyze the index in the usual way. &lt;br /&gt;&lt;br /&gt;In this example we have used on demand clause to Refresh the Materialized View. In order to refresh it, say for a DWH, use the dbms_mview package at the end of the ETL process. &lt;br /&gt;See: &lt;br /&gt;http://www.lc.leidenuniv.nl/awcourse/oracle/appdev.920/a96612/d_mview2.htm#94135&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-7431149239618742199?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/7431149239618742199/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=7431149239618742199' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/7431149239618742199'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/7431149239618742199'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/materialized-view.html' title='Materialized View'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-907348390031229038</id><published>2007-01-04T15:39:00.001-08:00</published><updated>2007-01-04T15:39:22.619-08:00</updated><title type='text'>Defragmenting Tables</title><content type='html'>This is the best way to defrag a table: &lt;br /&gt;&lt;br /&gt;alter table tablename &lt;br /&gt;move tablespace tablespacename &lt;br /&gt;&lt;br /&gt;But be careful doing this means the table's indexes will become unstable and so you need to rebuild all the indexes again: &lt;br /&gt;&lt;br /&gt;ALTER INDEX index_name REBUILD&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-907348390031229038?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/907348390031229038/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=907348390031229038' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/907348390031229038'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/907348390031229038'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/defragmenting-tables.html' title='Defragmenting Tables'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-6705936887047331434</id><published>2007-01-04T15:38:00.001-08:00</published><updated>2007-01-04T15:38:50.602-08:00</updated><title type='text'>Parallel Query Plan</title><content type='html'>Had a case of developing ETL in a 10g environment but the production environment being a 9i. When we released the ETL into production, there was a performance issue with one of the reports. Comparing the execution plan in 9i and 10g for the query looked like the problem was the parallel query not running in 9i. The init.ora parameters were also different, so it looked very likely that not running in parallel query was the problem. &lt;br /&gt;&lt;br /&gt;The init.ora parameters in 9i were changed to mirror the ones in 10g, yet after restarting with the new parameters, the query path still did not indicate a parallel run. So what was the problem? &lt;br /&gt;&lt;br /&gt;The problem is that the plan in 9i does not indicate parallel query in the same informative way as in 10g. In fact both databases were running in parallel, and the problem with the query was somewhere else. &lt;br /&gt;&lt;br /&gt;To make sure the query runs in parallel rather than relying on the plan, examine the following: &lt;br /&gt;&lt;br /&gt;BEFORE RUNNING: &lt;br /&gt;SQL&gt; select * from v$pq_sesstat; &lt;br /&gt;&lt;br /&gt;STATISTIC LAST_QUERY SESSION_TOTAL &lt;br /&gt;------------------------------ ---------- ------------- &lt;br /&gt;Queries Parallelized 0 0 &lt;br /&gt;DML Parallelized 0 0 &lt;br /&gt;DDL Parallelized 0 0 &lt;br /&gt;DFO Trees 0 0 &lt;br /&gt;Server Threads 0 0 &lt;br /&gt;Allocation Height 0 0 &lt;br /&gt;Allocation Width 0 0 &lt;br /&gt;Local Msgs Sent 0 0 &lt;br /&gt;Distr Msgs Sent 0 0 &lt;br /&gt;Local Msgs Recv'd 0 0 &lt;br /&gt;Distr Msgs Recv'd 0 0 &lt;br /&gt;&lt;br /&gt;AFTER RUNNING THE SQL WITH PARALLLEL HINT: &lt;br /&gt;SQL&gt; select * from V$pq_sesstat; &lt;br /&gt;&lt;br /&gt;STATISTIC LAST_QUERY SESSION_TOTAL &lt;br /&gt;------------------------------ ---------- ------------- &lt;br /&gt;Queries Parallelized 1 1 &lt;br /&gt;DML Parallelized 0 0 &lt;br /&gt;DDL Parallelized 0 0 &lt;br /&gt;DFO Trees 1 1 &lt;br /&gt;Server Threads 0 0 &lt;br /&gt;Allocation Height 7 0 &lt;br /&gt;Allocation Width 2 0 &lt;br /&gt;Local Msgs Sent 28 0 &lt;br /&gt;Distr Msgs Sent 28 0 &lt;br /&gt;Local Msgs Recv'd 63 0 &lt;br /&gt;Distr Msgs Recv'd 78 0 &lt;br /&gt;&lt;br /&gt;11 rows selected.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-6705936887047331434?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/6705936887047331434/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=6705936887047331434' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/6705936887047331434'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/6705936887047331434'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/parallel-query-plan.html' title='Parallel Query Plan'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-6471018652651934586</id><published>2007-01-04T15:37:00.001-08:00</published><updated>2007-01-04T15:37:41.244-08:00</updated><title type='text'>Using Bulk Collect Exceptions</title><content type='html'>Example to use Bulk Collect exceptions - new in 9i - &lt;br /&gt;&lt;br /&gt;CREATE TABLE t (text VARCHAR2(4)) &lt;br /&gt;&lt;br /&gt;declare &lt;br /&gt;type words_t is table of varchar2(10); &lt;br /&gt;words words_t := words_t ( 'dog', 'fish', 'cat', 'ball', 'bat', 'spoke', 'pad','elephant' ); &lt;br /&gt;&lt;br /&gt;bulk_errors exception; &lt;br /&gt;pragma exception_init ( bulk_errors, -24381 ); &lt;br /&gt;&lt;br /&gt;begin &lt;br /&gt;Forall j in words.first..words.last &lt;br /&gt;save exceptions &lt;br /&gt;insert into t ( text ) values ( words(j) ); &lt;br /&gt;&lt;br /&gt;exception &lt;br /&gt;&lt;br /&gt;when bulk_errors THEN &lt;br /&gt;for j in 1..sql%bulk_exceptions.count &lt;br /&gt;loop &lt;br /&gt;Dbms_Output.Put_Line ( &lt;br /&gt;sql%bulk_exceptions(j).error_index || ', ' || &lt;br /&gt;Sqlerrm(-sql%bulk_exceptions(j).error_code)||words(sql%bulk_exceptions(j).error_index)); &lt;br /&gt;end loop; &lt;br /&gt;&lt;br /&gt;end;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-6471018652651934586?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/6471018652651934586/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=6471018652651934586' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/6471018652651934586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/6471018652651934586'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/using-bulk-collect-exceptions.html' title='Using Bulk Collect Exceptions'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-126141010437971167</id><published>2007-01-04T15:36:00.000-08:00</published><updated>2007-01-04T15:37:00.251-08:00</updated><title type='text'>Regular Expressions to Show the First Occurance of n Upper Case Characters</title><content type='html'>I must admit, I still can't feel comfortable with regular expressions, but here is a neat one: &lt;br /&gt;&lt;br /&gt;SELECT (REGEXP_SUBSTR('AbcDERTK1DEcdhfjUWXvbDERTF' , '[[:upper:]]{5,}')) &lt;br /&gt;FROM dual &lt;br /&gt;&lt;br /&gt;It selects the first sequence of characters which has 5 upper cases together. &lt;br /&gt;So the result is: DERTK &lt;br /&gt;&lt;br /&gt;or &lt;br /&gt;&lt;br /&gt;SELECT (REGEXP_SUBSTR('AbcDEcdhfjUWXvbDERTF' , '[[:upper:]]{3,}')) &lt;br /&gt;FROM dual &lt;br /&gt;&lt;br /&gt;is : UWX&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-126141010437971167?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/126141010437971167/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=126141010437971167' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/126141010437971167'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/126141010437971167'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/regular-expressions-to-show-first.html' title='Regular Expressions to Show the First Occurance of n Upper Case Characters'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-2569797528253789251</id><published>2007-01-04T15:35:00.001-08:00</published><updated>2007-01-04T15:35:21.941-08:00</updated><title type='text'>How to Automate Max Partition Alert</title><content type='html'>http://www.dbaoncall.net/references/ht_max_partition_alert.html &lt;br /&gt;&lt;br /&gt;One of my ETL scripts once failed with the following error: &lt;br /&gt;ORA-14400: inserted partition key is beyond highest legal partition key &lt;br /&gt;&lt;br /&gt;So I decided to write an alert which would check my date partitioned tables and pre-warn me of the ones which I have to add partitions to. The problem was that the information writes the maximum date condition of a partition is in column high_value in user_tab_partitions table. This column is still a long type, and the information is in such a format: &lt;br /&gt;TO_DATE(' 2002-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', &lt;br /&gt;'NLS_CALENDAR=GREGORIAN') &lt;br /&gt;&lt;br /&gt;So the problem was to extract the date portion from a long column and evaluate the maximum date value per partitioned table. &lt;br /&gt;&lt;br /&gt;For this I wrote the following function first: &lt;br /&gt;--===================================================================== &lt;br /&gt;--= Function : MaxPartValue &lt;br /&gt;--= By : Potkin Nemat on 21-Jul-2003 &lt;br /&gt;--= Parameters : &lt;br /&gt;--= IN : p_table (name o fthe table to evaluate max date partition for. &lt;br /&gt;--= Return : max_date &lt;br /&gt;--= Version : &lt;br /&gt;--= 1.0 wrote the script &lt;br /&gt;--===================================================================== &lt;br /&gt;create or REPLACE FUNCTION MaxPartValue(p_table IN VARCHAR2) &lt;br /&gt;RETURN DATE &lt;br /&gt;IS &lt;br /&gt;&lt;br /&gt;TYPE cv_type IS REF CURSOR; &lt;br /&gt;cv cv_type; &lt;br /&gt;&lt;br /&gt;p_query VARCHAR2(2000); -- used to retrieve the value of the long &lt;br /&gt;column &lt;br /&gt;p_text VARCHAR2(32000); -- used to store the long value in for &lt;br /&gt;substr operation &lt;br /&gt;&lt;br /&gt;CURSOR csub(p_text IN VARCHAR2) IS &lt;br /&gt;SELECT to_date(substr(p_text,11,10),'YYYY-MM-DD') v_date &lt;br /&gt;FROM dual; &lt;br /&gt;&lt;br /&gt;max_date DATE; &lt;br /&gt;&lt;br /&gt;BEGIN &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;p_query := 'SELECT high_value FROM user_tab_partitions WHERE &lt;br /&gt;table_name = upper('; &lt;br /&gt;p_query := p_query ||''''|| p_table||''''||')'; &lt;br /&gt;&lt;br /&gt;max_date := to_date('01-JAN-01'); -- initialise max_date with a date &lt;br /&gt;in the past &lt;br /&gt;&lt;br /&gt;OPEN cv FOR p_query; &lt;br /&gt;LOOP &lt;br /&gt;FETCH cv INTO p_text; -- the value of the long column is now &lt;br /&gt;assigned to a varchar2 var &lt;br /&gt;EXIT WHEN CV%NOTFOUND; &lt;br /&gt;FOR csubrec IN csub(p_text) LOOP &lt;br /&gt;IF max_date &lt; csubrec.v_date THEN &lt;br /&gt;max_date := csubrec.v_date; -- record the max partition &lt;br /&gt;date per table &lt;br /&gt;END IF; &lt;br /&gt;END LOOP; &lt;br /&gt;END LOOP; &lt;br /&gt;&lt;br /&gt;RETURN max_date; &lt;br /&gt;&lt;br /&gt;END MAXpartVALUE; &lt;br /&gt;&lt;br /&gt;Once this function is created then it can be used in a simple query to list all the partitioned tables and their maximum date threshold partition: &lt;br /&gt;SELECT p.name,to_char(maxpartvalue(p.name),'dd-MON-yyyy') &lt;br /&gt;FROM user_part_key_columns p &lt;br /&gt;,user_tab_columns t &lt;br /&gt;WHERE p.object_type LIKE 'TABLE%' -- Oracle has spaces after &lt;br /&gt;TABLE in this column!! &lt;br /&gt;AND t.column_name = p.column_name &lt;br /&gt;AND t.table_name = p.NAME &lt;br /&gt;AND t.data_type = 'DATE' &lt;br /&gt;ORDER BY 2 DESC&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-2569797528253789251?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/2569797528253789251/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=2569797528253789251' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2569797528253789251'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2569797528253789251'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/how-to-automate-max-partition-alert.html' title='How to Automate Max Partition Alert'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-6086284503573633192</id><published>2007-01-04T15:34:00.001-08:00</published><updated>2007-01-04T15:34:25.378-08:00</updated><title type='text'>Counting strings</title><content type='html'>I posted this: &lt;br /&gt;http://www.oracle.com/technology/oramag/code/tips2005/022105.html &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Suppose we want to find out how many times 'aa' is repeated in a string, for example 'aakhgghghjaahhjghghaajghgaa', using SQL only. The SQL statement below can easily give the answer: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELECT (length('aakhgghghjaahhjghghaajghgaa') - &lt;br /&gt;length(REPLACE('aakhgghghjaahhjghghaajghgaa','aa')))/length('aa') &lt;br /&gt;FROM dual &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The code can be easily modified to extract the number of times any pattern is repeated in any string. &lt;br /&gt;&lt;br /&gt;Ilya Petrenko, a Sr.DBA at ICT Group Inc., in Newtown, PA. however came up with a neater solution: &lt;br /&gt;&lt;br /&gt;http://www.oracle.com/technology/oramag/code/tips2005/051605.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-6086284503573633192?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/6086284503573633192/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=6086284503573633192' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/6086284503573633192'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/6086284503573633192'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/counting-strings.html' title='Counting strings'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-1724763262064250539</id><published>2007-01-04T15:33:00.001-08:00</published><updated>2007-01-04T15:33:49.172-08:00</updated><title type='text'>Using Translate</title><content type='html'>I had this tip published before on : http://www.dbaoncall.net/references/tt_translate.html &lt;br /&gt;&lt;br /&gt;But just in case one day that site is no longer available, I thought I better keep a copy in my own blog too: &lt;br /&gt;&lt;br /&gt;If you have a varchar2 field and you want only the numerics, or perhaps some extra escape characters have found their way in, you can strip the field just to numerics by performing a translate such as below: &lt;br /&gt;select translate('abc123'||chr(10)||'F', &lt;br /&gt;'0'||translate('abc123'||chr(10)||'F', 'A1234567890', 'A'), '0') &lt;br /&gt;from ... &lt;br /&gt;&lt;br /&gt;This takes all the numbers out of the string and uses the resulting string as the translate so that the result is then only the numbers. Needless to say that one can also clean up the database using: &lt;br /&gt;&lt;br /&gt;update tableA &lt;br /&gt;set field = translate(field,'0'||translate(field,'A1234567890','A'),'0')&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-1724763262064250539?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/1724763262064250539/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=1724763262064250539' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/1724763262064250539'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/1724763262064250539'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/using-translate.html' title='Using Translate'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-7039488576564768245</id><published>2007-01-04T15:32:00.001-08:00</published><updated>2007-01-04T15:32:59.495-08:00</updated><title type='text'>Avoiding the Table Does not Exist Error when trying to drop it</title><content type='html'>A quick clever way to avoid Table Does not Exist Error when you have to drop the table in a pl/sql routine. This method saves you searching the data dictionary user_table: &lt;br /&gt;&lt;br /&gt;Begin &lt;br /&gt;execute immediate 'Drop table PRODUCT'; &lt;br /&gt;Exception &lt;br /&gt;when others then null; &lt;br /&gt;End;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-7039488576564768245?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/7039488576564768245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=7039488576564768245' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/7039488576564768245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/7039488576564768245'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/avoiding-table-does-not-exist-error.html' title='Avoiding the Table Does not Exist Error when trying to drop it'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-2865164792015405730</id><published>2007-01-04T15:31:00.000-08:00</published><updated>2007-01-04T15:32:16.831-08:00</updated><title type='text'>Resizing Temp Tablespace</title><content type='html'>These are the step by step instructions for resizing a Temp tablespace with AUTOEXTEND ON which has got way too big as a result of a rogue query. &lt;br /&gt;Change filenames and paths accordingly. &lt;br /&gt;&lt;br /&gt;The example here is good ebcause the Temp Tablespace is actually made up of two datafiles. I couldnt find any syntax examples for Temp tablespaces with more than one datafile. &lt;br /&gt;&lt;br /&gt;## Create another temporary tablespace &lt;br /&gt;CREATE TEMPORARY TABLESPACE TEMPXXX TEMPFILE '/u02/oracle/oradata/EV6PROD/temp03.dbf' &lt;br /&gt;SIZE 1000M REUSE AUTOEXTEND ON NEXT 8K MAXSIZE 2000M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1024K; &lt;br /&gt;&lt;br /&gt;## make it the default temporary tablespace for the database &lt;br /&gt;ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMPXXX; &lt;br /&gt;&lt;br /&gt;## drop the old tablespace and datafile to free space - CANNOT TAKE A TEMPORARY TABLESPACE OFFLINE &lt;br /&gt;##DROP TABLESPACE TEMP INCLUDING CONTENTS AND DATAFILES; hangs &lt;br /&gt;&lt;br /&gt;alter database tempfile '/u01/app/oracle/product/10.1.0/oradata/EV6PROD/temp01.dbf','/u02/oracle/oradata/EV6PROD/temp02.dbf' drop including datafiles; &lt;br /&gt;drop tablespace temp; &lt;br /&gt;-- rm /u02/oradata/EVWHP/temp02.dbf &lt;br /&gt;&lt;br /&gt;## recreate the old TEMP tablespace &lt;br /&gt;CREATE TEMPORARY TABLESPACE TEMP TEMPFILE '/u02/oracle/oradata/EV6PROD/temp01.dbf' &lt;br /&gt;SIZE 1000M REUSE AUTOEXTEND ON NEXT 8K MAXSIZE 2048M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1024K; &lt;br /&gt;&lt;br /&gt;## make it the default temporary tablespace for the database &lt;br /&gt;ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP; &lt;br /&gt;&lt;br /&gt;## drop the new, small tablespace and datafile to free space &lt;br /&gt;DROP TABLESPACE TEMPXXX INCLUDING CONTENTS AND DATAFILES &lt;br /&gt;&lt;br /&gt;Some good sources for TEMP Tablespace related stuff: &lt;br /&gt;&lt;br /&gt;http://www.orafaq.com/node/2 &lt;br /&gt;http://www.idevelopment.info/data/Oracle/DBA_tips/Tablespaces/TBS_3.shtml &lt;br /&gt;http://www.oracle.com/technology/oramag/oracle/05-jan/o15dba.html &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What can go wrong: &lt;br /&gt;&lt;br /&gt;The temp files which were deleted by the command: &lt;br /&gt;&lt;br /&gt;alter database tempfile '/u01/app/oracle/product/10.1.0/oradata/EV6PROD/temp01.dbf','/u02/oracle/oradata/EV6PROD/temp02.dbf' drop including datafiles; &lt;br /&gt;&lt;br /&gt;will not show when doing a du or ls -l, however df command still shows the space is allocated and not released if a process still thinks its using the file. &lt;br /&gt;&lt;br /&gt;lsof unix may show all the processes that still think the file is open but this didnt work for me. At the end I had to bounce the database, so much for trying to do this online :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-2865164792015405730?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/2865164792015405730/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=2865164792015405730' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2865164792015405730'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2865164792015405730'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/resizing-temp-tablespace.html' title='Resizing Temp Tablespace'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-4690727664387921688</id><published>2007-01-04T15:29:00.000-08:00</published><updated>2007-01-04T15:30:34.256-08:00</updated><title type='text'>The DBMS_UTILITY.GET_HASH_VALUE function</title><content type='html'>I always forget the name and syntax of this function. So I thought I better make a note of it on my blog. &lt;br /&gt;&lt;br /&gt;Parameters &lt;br /&gt;&lt;br /&gt;There are three IN parameters to the function &lt;br /&gt;&lt;br /&gt;Name :- Text string to be used as the basis of the hashing. &lt;br /&gt;&lt;br /&gt;Base :- The lowest number you want for the hash value. &lt;br /&gt;&lt;br /&gt;Hash_size:- Size of the hash table. &lt;br /&gt;&lt;br /&gt;Returns &lt;br /&gt;&lt;br /&gt;A numeric value which is derived from the IN parameter ‘name’.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-4690727664387921688?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/4690727664387921688/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=4690727664387921688' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/4690727664387921688'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/4690727664387921688'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/dbmsutilitygethashvalue-function.html' title='The DBMS_UTILITY.GET_HASH_VALUE function'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-1510453684687728184</id><published>2007-01-04T15:28:00.000-08:00</published><updated>2007-01-04T15:29:07.307-08:00</updated><title type='text'>Dropping an Index to Speed a Query</title><content type='html'>Had a complex query - generated by Microstrategy - which was taking over 2000 seconds to come back. Two main tables in the query, Table A had 256000 records and table B over 5million records. The execution plan was not using the index on table A as it should. By implementing an index hint the query time was reduced to 44 seconds. &lt;br /&gt;But being a Microstrategy report, this was not an option. &lt;br /&gt;&lt;br /&gt;I examined all the underlying tables and indexes in the query, and all were recently analyzed. &lt;br /&gt;&lt;br /&gt;At the end, the problem was solved by dropping the index on Table B, which was based on the prinmary key column of Table A. The query returned in 44 seconds once this index was dropped.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-1510453684687728184?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/1510453684687728184/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=1510453684687728184' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/1510453684687728184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/1510453684687728184'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/dropping-index-to-speed-query.html' title='Dropping an Index to Speed a Query'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-3175604050263096832</id><published>2007-01-04T15:27:00.002-08:00</published><updated>2007-01-04T15:28:22.274-08:00</updated><title type='text'>Oracle Project Raptor</title><content type='html'>Downloaded Oracle Project Raptor today on my PC. No problems in download and installation. It seems to be modelled on an older established product, pl/sql Developer, from Allround Automation. What I mean is that the layout is more similar to plsql developer than to Sql Navigator. &lt;br /&gt;&lt;br /&gt;But I have to say it seems much slower than plsql Developer in comparison.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-3175604050263096832?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/3175604050263096832/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=3175604050263096832' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/3175604050263096832'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/3175604050263096832'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/oracle-project-raptor.html' title='Oracle Project Raptor'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-4362269083826980365</id><published>2007-01-04T15:27:00.001-08:00</published><updated>2007-01-04T15:27:44.047-08:00</updated><title type='text'>How to Alert by email when errors occur in Log file</title><content type='html'>This is a nice and simple shell script: &lt;br /&gt;&lt;br /&gt;pass the alert log filename to the script below: &lt;br /&gt;&lt;br /&gt;cat $1 | grep ORA- &gt; alert.err &lt;br /&gt;&lt;br /&gt;if [ 'cat alert.err|wc -l' -gt 0 ] &lt;br /&gt;then &lt;br /&gt;mail -s "$0 $1 Errors" potkin@yourcompany.com &lt; alert.err &lt;br /&gt;fi &lt;br /&gt;&lt;br /&gt;The title of the message contains the script being executed ($0), the name of the log being searched ($1), and the lines that matched our initial search (ORA-) as the body of the message. &lt;br /&gt;&lt;br /&gt;Based on the principles introduced in this script, a larger one can be written and scheduled to execute at periodic intervals that will search the contents of the alert log (or another file of interest) and send an e-mail if any errors exist. Then the contents of the log can be moved to another file, so that only the most recent error messages will be sent via e-mail.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-4362269083826980365?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/4362269083826980365/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=4362269083826980365' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/4362269083826980365'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/4362269083826980365'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/how-to-alert-by-email-when-errors-occur.html' title='How to Alert by email when errors occur in Log file'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-2876289063706043378</id><published>2007-01-04T15:26:00.000-08:00</published><updated>2007-01-04T15:27:09.288-08:00</updated><title type='text'>Using Analytical NTILE() Function</title><content type='html'>I find it hard to remember the syntax of analytical functions, but this one - NTILE()- I came across today on Tom Kyte's site is easy to use and very useful &lt;br /&gt;&lt;br /&gt;As Tom puts it, its a "do-it-yourself parallelism". Its as if your table was partitioned and you were only interested in one portion of it. &lt;br /&gt;&lt;br /&gt;Lets use user_tables which we are all familiar with. Suppose I want to get a list of the oldest analysed tables. &lt;br /&gt;&lt;br /&gt;SELECT table_name &lt;br /&gt;FROM &lt;br /&gt;(SELECT table_name, &lt;br /&gt;last_analyzed, &lt;br /&gt;ntile(6) over &lt;br /&gt;(ORDER BY last_analyzed) nt &lt;br /&gt;FROM user_tables) &lt;br /&gt;WHERE nt=1&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-2876289063706043378?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/2876289063706043378/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=2876289063706043378' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2876289063706043378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/2876289063706043378'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/using-analytical-ntile-function.html' title='Using Analytical NTILE() Function'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-7597499847350466812</id><published>2007-01-04T15:25:00.002-08:00</published><updated>2007-01-04T15:26:08.251-08:00</updated><title type='text'>Problem with Sqllldr</title><content type='html'>Had a problem loading data from an ASCII file using sqlldr which is worth noting down. &lt;br /&gt;&lt;br /&gt;The dta file contained two description fields which were about 1200 characters long. &lt;br /&gt;Even though I had declared the relevant table columns as Varchar2(4000), the records were rejected saying Max Field Length exceeded. &lt;br /&gt;&lt;br /&gt;This was the original CTL file: &lt;br /&gt;&lt;br /&gt;LOAD DATA &lt;br /&gt;INFILE 'C:\PN\smq_list.asc' "str X'0a0d'" &lt;br /&gt;BADFILE 'C:\PN\smq_list.bad' &lt;br /&gt;DISCARDFILE 'C:\PN\smq_list.dsc' &lt;br /&gt;&lt;br /&gt;INTO TABLE "SMQ_LIST" &lt;br /&gt;&lt;br /&gt;FIELDS TERMINATED BY '$' &lt;br /&gt;OPTIONALLY ENCLOSED BY '"' &lt;br /&gt;TRAILING NULLCOLS &lt;br /&gt;(SMQ_CODE INTEGER EXTERNAL, &lt;br /&gt;SMQ_NAME CHAR, &lt;br /&gt;SMQ_LEVEL INTEGER EXTERNAL, &lt;br /&gt;SMQ_DESCRIPTION CHAR, &lt;br /&gt;SMQ_SOURCE CHAR, &lt;br /&gt;SMQ_NOTE CHAR, &lt;br /&gt;MEDDRA_VERSION CHAR, &lt;br /&gt;STATUS CHAR, &lt;br /&gt;SMQ_ALGORITHM CHAR &lt;br /&gt;) &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I wasted a lot of time thinking there was some espace character in the fields. Especially if I took just a chunk of the fields, the ctl worked. &lt;br /&gt;&lt;br /&gt;The problem was solved however by modifying the CTL file: &lt;br /&gt;&lt;br /&gt;LOAD DATA &lt;br /&gt;INFILE 'c:\pn\smq_list.asc' &lt;br /&gt;BADFILE 'c:\pn\smq_list.bad' &lt;br /&gt;DISCARDFILE 'c:\pn\smq_list.dsc' &lt;br /&gt;&lt;br /&gt;INTO TABLE "SMQ_LIST" &lt;br /&gt;&lt;br /&gt;FIELDS TERMINATED BY '$' &lt;br /&gt;OPTIONALLY ENCLOSED BY '"' &lt;br /&gt;TRAILING NULLCOLS &lt;br /&gt;(SMQ_CODE INTEGER EXTERNAL, &lt;br /&gt;SMQ_NAME CHAR, &lt;br /&gt;SMQ_LEVEL INTEGER EXTERNAL, &lt;br /&gt;SMQ_DESCRIPTION CHAR(2000), &lt;br /&gt;SMQ_SOURCE CHAR(2000), &lt;br /&gt;SMQ_NOTE CHAR, &lt;br /&gt;MEDDRA_VERSION CHAR, &lt;br /&gt;STATUS CHAR, &lt;br /&gt;SMQ_ALGORITHM CHAR &lt;br /&gt;) &lt;br /&gt;&lt;br /&gt;It looks like there is a default length for CHAR fields, and if we need it to be over that amount, we should specify in the CTL file.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-7597499847350466812?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/7597499847350466812/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=7597499847350466812' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/7597499847350466812'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/7597499847350466812'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/problem-with-sqllldr.html' title='Problem with Sqllldr'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-664870443850917854</id><published>2007-01-04T15:25:00.001-08:00</published><updated>2007-01-04T15:25:22.028-08:00</updated><title type='text'>Another dig at 10g Sql Advisory</title><content type='html'>First time I sat through a 10g demo, I was led to believe that this is it. No more need for Oracle practitioners to tune their sql, the new Sql Advisory feature will do this. Well I have written about a number of cases where the advisory just doesnt have a clue, here is yet another example of when only a clever human being can help. &lt;br /&gt;&lt;br /&gt;I have a large update, the outer loop I select is from the cursor below: &lt;br /&gt;&lt;br /&gt;CURSOR C1 &lt;br /&gt;is &lt;br /&gt;SELECT f.casenumberid,MAX(f.caseversionnumber) &lt;br /&gt;FROM f_safetyreport F &lt;br /&gt;GROUP BY F.CASENUMBERID; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now for the update I need to do, I a human being can see that I will not need to select the records which have max(f.caseversionnumber) of 1 &lt;br /&gt;&lt;br /&gt;so a re-write: &lt;br /&gt;CURSOR C1 &lt;br /&gt;IS &lt;br /&gt;SELECT f.casenumberid,MAX(f.caseversionnumber) &lt;br /&gt;FROM f_safetyreport F &lt;br /&gt;HAVING MAX(f.caseversionnumber) &gt; 1 &lt;br /&gt;GROUP BY F.CASENUMBERID; &lt;br /&gt;&lt;br /&gt;but the GROUP BY can slow things down, so only I a human being who understands the application is aware of a table which records the max(caseversionnumber) against a casenumberid, so here is a further rewrite which really spped things up: &lt;br /&gt;&lt;br /&gt;CURSOR C1 &lt;br /&gt;IS &lt;br /&gt;SELECT h.casenumberid,h.casemaxversion &lt;br /&gt;FROM h_caseversions H &lt;br /&gt;WHERE h.casemaxversion &gt; 1; &lt;br /&gt;&lt;br /&gt;There you go, clever human beings are still needed :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-664870443850917854?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/664870443850917854/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=664870443850917854' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/664870443850917854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/664870443850917854'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/another-dig-at-10g-sql-advisory.html' title='Another dig at 10g Sql Advisory'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-5906138277561752930</id><published>2007-01-04T10:09:00.001-08:00</published><updated>2007-01-04T10:09:23.406-08:00</updated><title type='text'>Re-writing an Update for Massive Performance Gain</title><content type='html'>Had the following update on a table with more than 5 million records, which was taking forever: &lt;br /&gt;&lt;br /&gt;DECLARE &lt;br /&gt;&lt;br /&gt;CURSOR c1 IS &lt;br /&gt;SELECT DISTINCT substr(rowid,1,13) &lt;br /&gt;FROM f_adversereaction; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;TYPE RowIdType IS TABLE OF VARCHAR2(18) INDEX BY BINARY_INTEGER; &lt;br /&gt;p_rowid RowIdType; &lt;br /&gt;&lt;br /&gt;TYPE p_idType IS TABLE OF f_adversereaction.adversereactionid%TYPE INDEX BY BINARY_INTEGER; &lt;br /&gt;p_id p_idType; &lt;br /&gt;&lt;br /&gt;BEGIN &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;OPEN c1; &lt;br /&gt;FETCH c1 BULK COLLECT INTO p_rowid; &lt;br /&gt;&lt;br /&gt;FORALL indx IN p_rowid.FIRST..p_rowid.LAST &lt;br /&gt;UPDATE f_adversereaction A &lt;br /&gt;SET a.originalsenderid = ( &lt;br /&gt;SELECT F.ORiginalsenderid &lt;br /&gt;FROM f_safetyreport F &lt;br /&gt;WHERE a.safetyreportid = f.safetyreportid ) &lt;br /&gt;WHERE a.ROWID LIKE p_rowid(indx)||'%'; &lt;br /&gt;END; &lt;br /&gt;&lt;br /&gt;Rewrote like this, and update was done in minutes: &lt;br /&gt;&lt;br /&gt;DECLARE &lt;br /&gt;&lt;br /&gt;CURSOR c1 IS &lt;br /&gt;SELECT a.adversereactionid,F.ORiginalsenderid &lt;br /&gt;FROM f_safetyreport F &lt;br /&gt;,f_adversereaction A &lt;br /&gt;WHERE a.safetyreportid = f.safetyreportid; &lt;br /&gt;&lt;br /&gt;TYPE p_idType IS TABLE OF f_adversereaction.adversereactionid%TYPE INDEX BY BINARY_INTEGER; &lt;br /&gt;p_id p_idType; &lt;br /&gt;&lt;br /&gt;TYPE p_SenderType IS TABLE OF f_adversereaction.originalsenderid%TYPE INDEX BY BINARY_INTEGER; &lt;br /&gt;p_sender p_senderType; &lt;br /&gt;&lt;br /&gt;BEGIN &lt;br /&gt;&lt;br /&gt;OPEN c1; &lt;br /&gt;FETCH c1 BULK COLLECT INTO p_id,p_sender; &lt;br /&gt;&lt;br /&gt;FORALL indx IN p_id.FIRST..p_id.LAST &lt;br /&gt;UPDATE f_adversereaction A &lt;br /&gt;SET a.originalsenderid = p_sender(indx) &lt;br /&gt;WHERE a.adversereactionid = p_id(indx); &lt;br /&gt;&lt;br /&gt;COMMIT; &lt;br /&gt;&lt;br /&gt;END;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-5906138277561752930?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/5906138277561752930/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=5906138277561752930' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/5906138277561752930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/5906138277561752930'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/re-writing-update-for-massive.html' title='Re-writing an Update for Massive Performance Gain'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-1865642810669901084</id><published>2007-01-04T10:08:00.001-08:00</published><updated>2007-01-04T10:08:41.128-08:00</updated><title type='text'>Regular Expressions</title><content type='html'>Ed Edwards from Florida Department Of Education asked me if we can use the new Oracle 10g Regular Expressions to rewrite this sql he had written to determine ALL the position of ',' in a string. &lt;br /&gt;&lt;br /&gt;select distinct text1, 'A "," is located in position ' || instr(text1, ',', 1, level) pos &lt;br /&gt;from (select text1 from test2) &lt;br /&gt;connect by level &lt;= length(text1) - length(replace(text1, ',')) &lt;br /&gt;order by text1 desc, pos asc &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I must say I really liked his clever way of repeating the rows as many times as the commas using the connectby level &lt;= numberof commas. &lt;br /&gt;&lt;br /&gt;Worthy of saving it as a tip.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-1865642810669901084?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/1865642810669901084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=1865642810669901084' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/1865642810669901084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/1865642810669901084'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/regular-expressions.html' title='Regular Expressions'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-7261177037464964113</id><published>2007-01-04T10:07:00.000-08:00</published><updated>2007-01-04T10:08:10.472-08:00</updated><title type='text'>Faster Update</title><content type='html'>If you have an update which is taking a long time even when you do it via forall: &lt;br /&gt;&lt;br /&gt;- copy the update procedure a few times, depending on how many cpu are available. &lt;br /&gt;- modify each of the above to update a portion of the table. &lt;br /&gt;- run the above copied procedure in parallel. &lt;br /&gt;&lt;br /&gt;So if your total update takes 4 hours, and you break the code into 4 each working on a range of the data, then this will reduce the update to 1 hour.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-7261177037464964113?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/7261177037464964113/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=7261177037464964113' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/7261177037464964113'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/7261177037464964113'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/faster-update.html' title='Faster Update'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-3528795962937527114</id><published>2007-01-04T10:06:00.000-08:00</published><updated>2007-01-04T10:07:04.058-08:00</updated><title type='text'>Flashback in 10g</title><content type='html'>Flashback in 10 g is really easy. &lt;br /&gt;&lt;br /&gt;Suppose you drop a table by mistake. This creates a BIN$ table in the recyclebin which you can not select from the BIN$ &lt;br /&gt;&lt;br /&gt;SQL&gt; select * from tab; &lt;br /&gt;TNAME TABTYPE CLUSTERID &lt;br /&gt;------------------------------ ------- ---------- &lt;br /&gt;BIN$04LhcpndanfgMAAAAAANPw==$0 TABLE &lt;br /&gt;&lt;br /&gt;To get it back simply type: &lt;br /&gt;&lt;br /&gt;SQL&gt; FLASHBACK TABLE RECYCLETEST TO BEFORE DROP; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For more info: &lt;br /&gt;http://www.oracle.com/technology/pub/articles/10gdba/week5_10gdba.html &lt;br /&gt;&lt;br /&gt;Interstingly: &lt;br /&gt;plsql developer does not show the bin$ tables in the tree list panel but sqlnavigator does.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-3528795962937527114?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/3528795962937527114/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=3528795962937527114' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/3528795962937527114'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/3528795962937527114'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/flashback-in-10g.html' title='Flashback in 10g'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-4245847521468649222</id><published>2007-01-04T10:03:00.000-08:00</published><updated>2007-01-04T10:06:25.200-08:00</updated><title type='text'>Dropping a Primary Key</title><content type='html'>If a primary key is referenced by foreign key from other tables, its no good disabling the foreign keys, you need to drop them before dropping the primary key.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-4245847521468649222?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/4245847521468649222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=4245847521468649222' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/4245847521468649222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/4245847521468649222'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/dropping-primary-key.html' title='Dropping a Primary Key'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-4010243488821401358</id><published>2007-01-04T10:01:00.000-08:00</published><updated>2007-01-04T10:02:10.904-08:00</updated><title type='text'>Submitting the Suggested Oracle Profile</title><content type='html'>DECLARE &lt;br /&gt;l_sql_tune_task_id VARCHAR2(20); &lt;br /&gt;&lt;br /&gt;BEGIN &lt;br /&gt;&lt;br /&gt;l_sql_tune_task_id := DBMS_SQLTUNE.accept_sql_profile (task_name =&gt; 'a16',name =&gt; 'a16'); &lt;br /&gt;DBMS_OUTPUT.put_line('l_sql_tune_task_id: ' l_sql_tune_task_id); &lt;br /&gt;&lt;br /&gt;END;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-4010243488821401358?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/4010243488821401358/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=4010243488821401358' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/4010243488821401358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/4010243488821401358'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/submitting-suggested-oracle-profile.html' title='Submitting the Suggested Oracle Profile'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-5987339840410788151</id><published>2007-01-04T10:00:00.000-08:00</published><updated>2007-01-04T10:01:10.168-08:00</updated><title type='text'>Temp Tablespace Unable to Extend</title><content type='html'>I had a complex query generated by a Microstrategy report. It kept falling over with a "unable to extend Temp Tablespace". I knew its to do with the group by statement as it ran ok without the group by.The Temp tablespace was 4 GB which I tend to think should be enough. &lt;br /&gt;&lt;br /&gt;I searched a lot on the internet for solution of this problem. Tried all the clever things using the no_parallel hint, increasing the sort_area_size, the pga_aggregate_target, used the new 10g facility to suggest a new profile which changed the plan but all to no avail in solving the temp tablespace problem. &lt;br /&gt;&lt;br /&gt;Finally I went back to the drawing board and re-examined the query generated by microstrategy. I then relaized that two of the tables in the join were not needed at all to get the columns and the aggregate we wanted and that was the solution to the problem. &lt;br /&gt;&lt;br /&gt;Conclusion is who said with 10g there is no more need for DBA???&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-5987339840410788151?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/5987339840410788151/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=5987339840410788151' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/5987339840410788151'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/5987339840410788151'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/temp-tablespace-unable-to-extend.html' title='Temp Tablespace Unable to Extend'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-5513248655017473442</id><published>2007-01-04T09:59:00.000-08:00</published><updated>2007-01-04T10:00:33.269-08:00</updated><title type='text'>10g Sql Advisory</title><content type='html'>grant advisor to&lt;br /&gt;&lt;br /&gt;wasted a lot of time trying to figure out why dbms_sql.submit kept claiming that table or view does not exist.&lt;br /&gt;&lt;br /&gt;It turned out I had created the tables while logged in as my schema but as sysdba using plsql developer!&lt;br /&gt;&lt;br /&gt;SQL &gt; CREATE or REPLACE PROCEDURE create_tuning_task IS&lt;br /&gt;2 tuning_task VARCHAR2(30);&lt;br /&gt;3 sqltext CLOB;&lt;br /&gt;4 BEGIN&lt;br /&gt;5 sqltext := 'select cust_name,count(*)'&lt;br /&gt;6 ' from customer, cust_order'&lt;br /&gt;7 ' where customer.cust_no = cust_order.cust_no'&lt;br /&gt;8 ' and customer.cust_no = 8'&lt;br /&gt;9 ' group by cust_name';&lt;br /&gt;10 tuning_task := DBMS_SQLTUNE.CREATE_TUNING_TASK(&lt;br /&gt;11 sql_text =&gt; sqltext,&lt;br /&gt;12 user_name =&gt; 'SYS',&lt;br /&gt;13 scope =&gt; 'COMPREHENSIVE',&lt;br /&gt;14 time_limit =&gt; 30,&lt;br /&gt;15 task_name =&gt; 'CUST_ORDERS',&lt;br /&gt;16 description =&gt; 'Tuning effort for counting customer orders');&lt;br /&gt;17 END create_tuning_task;&lt;br /&gt;18 /&lt;br /&gt;&lt;br /&gt;SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK( 'CUST_ORDERS') FROM DUAL;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-5513248655017473442?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/5513248655017473442/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=5513248655017473442' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/5513248655017473442'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/5513248655017473442'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/10g-sql-advisory.html' title='10g Sql Advisory'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7198004864285840789.post-7771214999882758831</id><published>2007-01-04T09:58:00.000-08:00</published><updated>2007-01-04T09:59:17.856-08:00</updated><title type='text'>Parallel Query</title><content type='html'>This is a good link:&lt;a href="http://www.oracle.com/technology/oramag/oracle/05-may/o35dba.html"&gt;http://www.oracle.com/technology/oramag/oracle/05-may/o35dba.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;when tables are created with degrees &gt; 1 Oracle can assume a parallel execution plan of a large query.&lt;br /&gt;&lt;br /&gt;In the plan you can see this by PX&lt;br /&gt;&lt;br /&gt;Its a good idea to have the parameter parallel_automatic_tuning set to TRUE.&lt;br /&gt;&lt;br /&gt;To disable parallel query use no_parallel hint./* no_parallel(T1) no_paralle(T2) */&lt;br /&gt;&lt;br /&gt;Use the table aliases as in the query.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7198004864285840789-7771214999882758831?l=potoracle.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://potoracle.blogspot.com/feeds/7771214999882758831/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7198004864285840789&amp;postID=7771214999882758831' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/7771214999882758831'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7198004864285840789/posts/default/7771214999882758831'/><link rel='alternate' type='text/html' href='http://potoracle.blogspot.com/2007/01/parallel-query.html' title='Parallel Query'/><author><name>potoracle</name><uri>http://www.blogger.com/profile/17572806355090276733</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://i12.tinypic.com/2ce3khw.jpg'/></author><thr:total>0</thr:total></entry></feed>
