<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Andrew Fraser DBA &#187; Bugs</title>
	<atom:link href="http://andrewfraserdba.com/category/bugs/feed/" rel="self" type="application/rss+xml" />
	<link>http://andrewfraserdba.com</link>
	<description>Oracle DBA (plus SQL Server)</description>
	<lastBuildDate>Fri, 06 Apr 2012 09:24:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Bug (ora-2019 or ora-2069) with User Defined Functions Insert/Update over Database Links</title>
		<link>http://andrewfraserdba.com/2009/03/05/bug-ora-2019-or-ora-2069-with-user-defined-functions-insertupdate-over-database-links/</link>
		<comments>http://andrewfraserdba.com/2009/03/05/bug-ora-2019-or-ora-2069-with-user-defined-functions-insertupdate-over-database-links/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 11:00:56 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[Bugs]]></category>

		<guid isPermaLink="false">http://www.andrewfraserdba.com/?p=66</guid>
		<description><![CDATA[If you try to insert or update across a database link some values called by a user defined function: insert into mytable@remote (mycol) values ( myfunction ('01-JAN-2009') ) ; That will fail with either: ORA-02019: connection description for remote database &#8230; <a href="http://andrewfraserdba.com/2009/03/05/bug-ora-2019-or-ora-2069-with-user-defined-functions-insertupdate-over-database-links/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you try to insert or update across a database link some values called by a user defined function:</p>
<pre class="brush:sql">insert into mytable@remote (mycol) values ( myfunction ('01-JAN-2009') ) ;</pre>
<p>That will fail with either:</p>
<pre class="brush:sql">ORA-02019: connection description for remote database not found</pre>
<p>or</p>
<pre class="brush:sql">ORA-02069: global_names parameter must be set to TRUE for this operation</pre>
<p>There are three workarounds to the problem:</p>
<p><strong>1) </strong>create database links in <strong>both</strong> directions, local-&gt;remote and remote-&gt;local.</p>
<p><strong>2) </strong>Specify “@database link name” when calling your user defined function, like this:</p>
<pre class="brush:sql">insert into mytable@remote (mycol) values ( myfunction@remote ('01-JAN-2009') ) ;</pre>
<p>That requires that the function exist in the remote database.</p>
<p><strong>3) </strong>Insert the data first into a local table, then copy that data over to the remote database, like this:</p>
<pre class="brush:sql">insert into mytable_local values ( myfunction ('01-JAN-2009') ) ;
insert into mytable@remote select * from mytable_local ;
delete mytable_local ;</pre>
<p>And a fourth option, of pursuing a complete fix:<br />
<strong>4) </strong>Raise this as a bug with Oracle Support and have them provide a complete fix, rather than resort to workarounds. This issue was actually logged as bug number 671775 way back in 1998, but was closed off on the grounds that there were easy workaround available.</p>
<p>Reference &#8211; Metalink Note 342320.1</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2009/03/05/bug-ora-2019-or-ora-2069-with-user-defined-functions-insertupdate-over-database-links/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>10.2.0.3 patch fails if database word size had ever been changed in the past</title>
		<link>http://andrewfraserdba.com/2007/05/02/10203-patch-fails-if-database-word-had-ever-been-changed-in-the-past/</link>
		<comments>http://andrewfraserdba.com/2007/05/02/10203-patch-fails-if-database-word-had-ever-been-changed-in-the-past/#comments</comments>
		<pubDate>Wed, 02 May 2007 14:38:11 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[Bugs]]></category>

		<guid isPermaLink="false">http://andrewfraser.wordpress.com/2007/05/02/10203-patch-fails-if-database-word-had-ever-been-changed-in-the-past/</guid>
		<description><![CDATA[Thanks to Chris Carr for pointing out this: If you are upgrading or patching to 10.2.0.3 and the word size is different to the word size when the database was created the upgrade will fail with an ora-600. This applies &#8230; <a href="http://andrewfraserdba.com/2007/05/02/10203-patch-fails-if-database-word-had-ever-been-changed-in-the-past/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Thanks to Chris Carr for pointing out this:</p>
<p>If you are upgrading or patching to 10.2.0.3 and the word size is different to the word size when the database was created the upgrade will fail with an ora-600. This applies even if the wordsize has been changed in an interim upgrade i.e. 8.1.7 32bit upgraded to 9.2.0 64bit will not upgrade to 10.2.0.3 64 bit, (but will upgrade to 10.2.0.3 32 bit).</p>
<p>To identify whether a database was created as 32-bit or 64-bit, execute the following SQL statement:</p>
<p><code>SQL&gt; select metadata from sys.kopm$ ;<code></p>
<p>If the output references the string 'B023' then it indicates that the database was created as 32-bit If the output references the string 'B047' then it indicates that the database was created as 64-bit</p>
<p>Metalink note on this is <a href="https://metalink.oracle.com/metalink/plsql/f?p=130:14:5544754951127751721::::p14_database_id,p14_docid,p14_show_header,p14_show_help,p14_black_frame,p14_font:NOT,412271.1,1,1,1,helvetica#OCCURRENCE">Note 412271.1</a>.</p>
<p>There is a patch to fix this before applying 10.2.0.3, although it is available on Linux, Solaris, HPUX and AIX only so far, not on Windows for some reason.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2007/05/02/10203-patch-fails-if-database-word-had-ever-been-changed-in-the-past/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>And on the seventh day, God fiddled with His NLS settings</title>
		<link>http://andrewfraserdba.com/2007/04/25/and-on-the-seventh-day-god-fiddled-with-his-nls-settings/</link>
		<comments>http://andrewfraserdba.com/2007/04/25/and-on-the-seventh-day-god-fiddled-with-his-nls-settings/#comments</comments>
		<pubDate>Wed, 25 Apr 2007 09:45:55 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Character sets]]></category>

		<guid isPermaLink="false">http://andrewfraser.wordpress.com/2007/04/25/and-on-the-seventh-day-god-fiddled-with-his-nls-settings/</guid>
		<description><![CDATA[This would seem to be pretty authoritative: &#8220;And on the seventh day God ended his work which He had made; and he rested on the seventh day from all his work which He had made. And God blessed the seventh &#8230; <a href="http://andrewfraserdba.com/2007/04/25/and-on-the-seventh-day-god-fiddled-with-his-nls-settings/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This would seem to be pretty authoritative:</p>
<blockquote><p>&#8220;And on the seventh day God ended his work which He had made; and he rested on the seventh day from all his work which He had made. And God blessed the seventh day, and sanctified it; because that in it he had rested from all his work which God created and made&#8221; (Genesis 2:2-3).</p></blockquote>
<p>But, only in America.<a href="http://andrewfraser.wordpress.com/2007/04/25/and-on-the-seventh-day-god-fiddled-with-his-nls-settings/#more-38">*</a></p>
<p>In many other NLS territories, Saturday is the sixth day of the week, not the seventh:</p>
<pre class="brush:sql">SQL> alter session set NLS_TERRITORY = 'AMERICA';

Session altered.

SQL> select to_char(sysdate+3,'D Dy') from dual;

TO_CH
-----
7 Sat

SQL> alter session set NLS_TERRITORY='UNITED KINGDOM';

Session altered.

SQL>select to_char(sysdate+3,'D Dy') from dual;

TO_CH
-----
6 Sat</pre>
<p>Now that&#8217;s a real pain, because different Windows PCs will inevitably end up having different registry/environment variable settings for NLS_LANG (NLS_TERRITORY forms the middle part of the NLS_LANG variable). And NLS_LANG also gets set a lot in unix .profile&#8217;s. And those all override the databases settings.</p>
<p>So this week when I had users reporting different results from different PCs, I had initially assumed tnsnames.ora differences were pointing them off to different databases. But really it was because they were running code like this:</p>
<pre class="brush:sql">select address, 'These customers want visited Saturdays'
from customer
where to_char(workdate,'D') = 6 ;</pre>
<p>The fix is to name the day of the week rather than count to it:</p>
<pre class="brush:sql">select address, 'These customers want visited Saturdays'
from customer
where to_char(workdate,'Dy') = 'Sat' ;</pre>
<p>Essentially this issue makes the &#8220;D&#8221; date format unusable.</p>
<p>If code like the above absolutely couldn&#8217;t be changed, then a logon trigger would be the only way to set NLS_TERRITORY the same for all users:</p>
<pre class="brush:sql">create or replace trigger my_logon_trigger
after logon on database
begin
execute immediate 'alter session set nls_territory = ''UNITED KINGDOM'' ' ;
end ;
/</pre>
<p>See <a href="http://asktom.oracle.com/tkyte/Misc/NLSDateFormat.html">Tom Kyte on NLS Date Format</a> and <a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:433227339578">asktom &#8220;language issue&#8221;</a></p>
<p><span id="more-38"></span>* I&#8217;m exaggerating: most countries follow American usage. It&#8217;s Europe which has the Saturday=6 convention, along with some of Europe&#8217;s former possessions: including Mexico (European numbering), but not Canada (American numbering). India, perhaps surprisingly, follows American rather than British day numbering. Israel sticks with the Biblical definition. For extra confusion, some Muslim countries set Friday as their seventh day:</p>
<pre class="brush:sql">SQL> alter session set NLS_TERRITORY = 'EGYPT';

Session altered.

SQL> select to_char(sysdate+3,'D Dy') from dual;

TO_CH
-----
1 Sat</pre>
<p>But others (Turkey, Indonesia) go with European numbering.</p>
<p>Bottom line, keep the &#8220;D&#8221; date format out of your code.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2007/04/25/and-on-the-seventh-day-god-fiddled-with-his-nls-settings/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Data block corruption cleared with alter system flush buffer_cache</title>
		<link>http://andrewfraserdba.com/2007/04/19/data-block-corruption-cleared-with-alter-system-flush-buffer_cache/</link>
		<comments>http://andrewfraserdba.com/2007/04/19/data-block-corruption-cleared-with-alter-system-flush-buffer_cache/#comments</comments>
		<pubDate>Thu, 19 Apr 2007 14:45:46 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Rman]]></category>

		<guid isPermaLink="false">http://andrewfraser.wordpress.com/2007/04/19/data-block-corruption-cleared-with-alter-system-flush-buffer_cache/</guid>
		<description><![CDATA[So I had: ORA-08103: object no longer exists being reported on SQL affecting one application table. But that table existed ok in dba_tables, could be described ok, and selects restricted to its indexed columns returned data ok. Suspicion was some &#8230; <a href="http://andrewfraserdba.com/2007/04/19/data-block-corruption-cleared-with-alter-system-flush-buffer_cache/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So I had:<br />
<code>ORA-08103: object no longer exists</code><br />
being reported on SQL affecting one application table. But that table existed ok in dba_tables, could be described ok, and selects restricted to its indexed columns returned data ok.</p>
<p>Suspicion was some sort of data block corruption. Rman backup logs had not reported any corrpution, but dbverify did find some corrupt blocks. Those blocks were not associated with any record in dba_extents though.</p>
<p>All that is curious enough, but it is the fix which was the real surprise. Running:<br />
<code>SQL&gt; alter system flush buffer_cache ;</code><br />
Fixed the problem. Implication of that is that there is intermittent data block corruption, and that  table was corrupt at the time it was first read into cache, and clean again (on disk) by the time I came along to look at it.</p>
<p>Dbverify later on also switched over to giving the datafiles a clean bill of health.</p>
<p>What&#8217;s the root cause? Don&#8217;t know (yet), but intermittent disk or memory hardware failure seems  the most likely. Nothing reported in server logs though.</p>
<p>This on Oracle 10.1.0.4.0 Enterprise Edition on Microsoft Windows Server 2003 Standard Edition Service Pack 1 on Intel Xeon 3.2GHz.</p>
<p>The dbverify syntax I used was like:<br />
<code>dbv file=D:\ORACLE\ORADATA\SYSTEM01.DBF logfile=4.log</code><br />
I didn&#8217;t have to specify block size because database was at the default block size for that version of dbv (seen with <code>dbv help=y</code>).</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2007/04/19/data-block-corruption-cleared-with-alter-system-flush-buffer_cache/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bug? with wrong results from all_objects in stored plsql procedures</title>
		<link>http://andrewfraserdba.com/2007/03/02/bug-with-wrong-results-from-all_objects-in-stored-plsql-procedures/</link>
		<comments>http://andrewfraserdba.com/2007/03/02/bug-with-wrong-results-from-all_objects-in-stored-plsql-procedures/#comments</comments>
		<pubDate>Fri, 02 Mar 2007 12:44:49 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://andrewfraser.wordpress.com/2007/03/02/bug-with-wrong-results-from-all_objects-in-stored-plsql-procedures/</guid>
		<description><![CDATA[Wouldn&#8217;t it be nice if sql code produced the same result, regardless of whether it is inside a stored procedure or is a standalone plsql block? But that&#8217;s not what happens when the all_ views are used. Run this code &#8230; <a href="http://andrewfraserdba.com/2007/03/02/bug-with-wrong-results-from-all_objects-in-stored-plsql-procedures/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Wouldn&#8217;t it be nice if sql code produced the same result, regardless of whether it is inside a stored procedure or is a standalone plsql block? But that&#8217;s not what happens when the <em>all_ </em>views are used.</p>
<p>Run this code to see the anomaly for yourself:</p>
<p><code>set serverout on<br />
declare<br />
&nbsp;&nbsp;var1 number ;<br />
begin<br />
&nbsp;&nbsp;select count(*) into var1 from all_objects ;<br />
&nbsp;&nbsp;dbms_output.put_line('all_objects: '||var1) ;<br />
end ;<br />
/<br />
create or replace procedure af_temp as<br />
&nbsp;&nbsp;var1 number ;<br />
begin<br />
&nbsp;&nbsp;select count(*) into var1 from all_objects ;<br />
&nbsp;&nbsp;dbms_output.put_line('all_objects: '||var1) ;<br />
end ;<br />
/<br />
exec af_temp ;<br />
drop procedure af_temp ;</code></p>
<p>It&#8217;s the exact same plsql each time, but very different results reported. For example:</p>
<p><code>all_objects: 13501</code></p>
<p><code>PL/SQL procedure successfully completed.</code></p>
<p><code>Procedure created.</code><br />
<code><br />
all_objects: 4929</code></p>
<p><code>PL/SQL procedure successfully completed.</code></p>
<p><code>Procedure dropped.</code></p>
<p>This behaviour appears to occur on all versions &#8211; I tested from 7.3 through 10gR2. The biggest discrepancies in results seem to be with DBA users other than SYS, but all users show some discrepancy.</p>
<p>This issue doesn&#8217;t occur with the <em>dba_</em> views, so best to use them instead in stored plsql objects. That does mean explicitly granting select privileges on the dba_ views being used in stored procedures, which isn&#8217;t necessary for the <em>all_</em> views.</p>
<p>So, is this a bug? I can&#8217;t see any mention of it all in metalink.</p>
<p>It&#8217;s not just an academic issue either: it caused <a href="http://andrewfraser.wordpress.com/2007/02/01/using-10g-datapump-and-scheduler-to-copy-schemas/#more-19">this code of mine</a> to fail to find and drop the objects it was meant to drop.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2007/03/02/bug-with-wrong-results-from-all_objects-in-stored-plsql-procedures/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Pre 9202/9014: Advanced queuing runs away with server memory.</title>
		<link>http://andrewfraserdba.com/2007/01/15/pre-92029014-advanced-queuing-runs-away-with-server-memory/</link>
		<comments>http://andrewfraserdba.com/2007/01/15/pre-92029014-advanced-queuing-runs-away-with-server-memory/#comments</comments>
		<pubDate>Mon, 15 Jan 2007 14:00:35 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://andrewfraser.wordpress.com/2007/01/15/pre-92029014-advanced-queuing-runs-away-with-server-memory/</guid>
		<description><![CDATA[Using the below memory listing script, I found two databases with large PGAs. That was strange since pga_aggregate_target was unset, sort_area_size was just 64k, and there were very few sessions. Checking PGA at session level showed the QMN sessions had &#8230; <a href="http://andrewfraserdba.com/2007/01/15/pre-92029014-advanced-queuing-runs-away-with-server-memory/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Using the <a href="http://andrewfraser.wordpress.com/2007/01/15/script-run-against-every-running-database-listing-total-oracle-memory-sgapga/">below memory listing script</a>, I found two databases with large PGAs. That was strange since pga_aggregate_target was unset, sort_area_size was just 64k, and there were very few sessions. Checking PGA at session level showed the QMN sessions had high memory usage (over 200mb each). Which pointed to bug 2227360 &#8220;QMN process leaking memory&#8221;</p>
<p>It is fixed in 9.0.1.4/9.2.0.2 and above, but I was on 9.2.0.1. So the workaround is to kill the QMN (=AQ) sessions. Sounds drastic, but oracle restarts the processes apparently cleanly, with just a message in the alert log like:</p>
<blockquote><p><code>Restarting dead background process QMN0<br />
QMN0 started with pid=9</code></p></blockquote>
<p>And that is the memory then freed up &#8211; for a while at least, you have to be prepared to kill those sessions every so often as the memory leaks build up, if, that is, you can&#8217;t patch up.</p>
<p>I used the below script to kill the sessions. I didn&#8217;t need to use the drastic &#8220;<code>kill -9</code>&#8221; on this occasion, but sometimes sessions take forever to go without that.</p>
<pre class="brush:sql">select 'alter system kill session '''||s.sid||','||s.serial#||''' ;',
'kill -9 '||p.spid
from v$session s, v$process p
where s.paddr = p.addr
and s.program like '%QMN%'
/</pre>
<p>Reference: <a href="https://metalink.oracle.com/metalink/plsql/showdoc?db=NOT&amp;id=233101.1&amp;blackframe=1">Metalink Note 233101.1</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2007/01/15/pre-92029014-advanced-queuing-runs-away-with-server-memory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

