From oracle-l-bounce@freelists.org  Fri Sep  9 13:34:07 2005
Return-Path: <oracle-l-bounce@freelists.org>
Received: from air891.startdedicated.com (root@localhost)
 by orafaq.com (8.12.10/8.12.10) with ESMTP id j89IY79N023186
 for <oracle-l@orafaq.com>; Fri, 9 Sep 2005 13:34:07 -0500
X-ClientAddr: 206.53.239.180
Received: from turing.freelists.org (freelists-180.iquest.net [206.53.239.180])
 by air891.startdedicated.com (8.12.10/8.12.10) with ESMTP id j89IXfIP023121
 for <oracle-l@orafaq.com>; Fri, 9 Sep 2005 13:33:47 -0500
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 6A88B1EB667;
 Fri,  9 Sep 2005 13:31:40 -0500 (EST)
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 18402-05; Fri, 9 Sep 2005 13:31:40 -0500 (EST)
Received: from turing (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id D836F1EB666;
 Fri,  9 Sep 2005 13:31:39 -0500 (EST)
Message-ID: <5B257A26B4845C469B87871B6CEFE5070331AD59@usnjc04wmx003.tdwaterhouse.com>
From: JayMiller@TDWaterhouse.com
To: DGoulet@vicr.com, oracle-l@freelists.org
Subject: RE: Query started getting 1722 error - interesting explanation wh
 y
Date: Fri, 9 Sep 2005 14:29:16 -0400 
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C5B56C.62D1DEB0"
X-archive-position: 25241
X-ecartis-version: Ecartis v1.0.0
Sender: oracle-l-bounce@freelists.org
Errors-To: oracle-l-bounce@freelists.org
X-original-sender: JayMiller@TDWaterhouse.com
Precedence: normal
Reply-To: JayMiller@TDWaterhouse.com
X-list: oracle-l
X-Virus-Scanned: by amavisd-new-20030616-p9 (Debian) at avenirtech.net
X-mailscan-MailScanner-Information: Please contact the ISP for more information
X-mailscan-MailScanner: Found to be clean
X-MailScanner-From: oracle-l-bounce@freelists.org
X-Spam-Level: 
X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on 
 air891.startdedicated.com
X-Spam-Status: No, hits=-3.1 required=5.0 tests=AWL,BAYES_00,HTML_50_60,
 HTML_FONTCOLOR_UNKNOWN,HTML_MESSAGE,NO_REAL_NAME autolearn=no 
 version=2.63
------_=_NextPart_001_01C5B56C.62D1DEB0
Content-Type: text/plain

Hmm, I think I checked that at the time but a week and a half later I can't
say for certain.  Currently that is not the case but currently it's back to
the old explain plan as well so that doesn't say anything.

 

Thanks,

Jay Miller

Sr. Oracle DBA

x68355

 

-----Original Message-----
From: Goulet, Dick [mailto:DGoulet@vicr.com] 
Sent: Friday, September 09, 2005 2:23 PM
To: Miller, Jay; oracle-l@freelists.org
Subject: RE: Query started getting 1722 error - interesting explanation why

 

Jay,

 

    Did that varchar2 have numbers only in it before it stopped working and
then picked up one with an alpha character?  I've seen that one more than I
care to remember.

 

  _____  

From: oracle-l-bounce@freelists.org [mailto:oracle-l-bounce@freelists.org]
On Behalf Of JayMiller@TDWaterhouse.com
Sent: Friday, September 09, 2005 2:16 PM
To: oracle-l@freelists.org
Subject: Query started getting 1722 error - interesting explanation why

I got a call from a developer the other week complaining that a query in QA
had started giving an ora-1722.  It had worked fine for several months and
the identical query was working fine in production.

 

Select count(1) 

from prod.job_profile jp

where step_id < 9999

and not exists (select 'x' from prod.job_log jl

                where jl.job_id = jp.job_id

                and ( jl.status in ('C', 'EI') )

                and  jl.batch_id in (select to_number(text_value)

                                     from prod.batch_parameter

                                     where name = 'BATCH_ID'));

 

Investigating confirmed this, along with the fact that the query was
comparing a string (jl.batch_id) with a number (to_number(text_value)).  But
why did it suddenly stop working and why did it still work in production?

 

Comparing explain plans between QA and production I saw that they were
different (statistics had changed during QA testing).  The query that failed
was using an index on jl.batch_id.  

 

Apparently Oracle automatically took care of converting the string to a
number *unless* the number was being used to access an index on the varchar2
column.  Interesting behavior.  I can see why it might work that way but
it's certainly not intuitive. 

 

Of course explaining this to the developer took quite a while.  "It worked
before, why shouldn't it work now?  What's wrong with Oracle?"

 

Oracle 9.2.0.6

 

 

Jay Miller

Sr. Oracle DBA

 

.

  _____  

This message is confidential and sent by TD Waterhouse solely for use
by the intended recipient. If you are not the intended recipient, you
are hereby notified that any use, distribution or copying of this
communication is strictly prohibited. This should not be deemed as an
offer or solicitation, to buy or sell any product. Any 3rd party
information contained herein was prepared by sources deemed reliable,
but is not guaranteed. TD Waterhouse does not accept electronic
instructions that would require an original signature. Information
received by or sent from TD Waterhouse is stored, subject to review,
and may be produced to regulatory authorities or others with a legal
right to such. 


------_=_NextPart_001_01C5B56C.62D1DEB0
Content-Type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">


<meta name=Generator content="Microsoft Word 10 (filtered)">

<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
p.MsoAutoSig, li.MsoAutoSig, div.MsoAutoSig
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p
	{margin-right:0in;
	margin-left:0in;
	font-size:12.0pt;
	font-family:"Times New Roman";}
span.emailstyle17
	{font-family:Arial;
	color:navy;}
span.EmailStyle21
	{font-family:Arial;
	color:navy;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Hmm, I think I checked that at the time but
a week and a half later I can't say for certain.&nbsp; Currently that is
not the case but currently it's back to the old explain plan as well so
that doesn't say anything.</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<div>

<p class=MsoAutoSig><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Thanks,</span></font></p>

<p class=MsoAutoSig><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Jay Miller</span></font></p>

<p class=MsoAutoSig><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Sr. Oracle DBA</span></font></p>

<p class=MsoAutoSig><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>x68355</span></font></p>

</div>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>-----Original Message-----<br>
<b><span style='font-weight:bold'>From:</span></b> Goulet, Dick
[mailto:DGoulet@vicr.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> Friday, September 09, 2005
2:23 PM<br>
<b><span style='font-weight:bold'>To:</span></b> Miller, Jay;
oracle-l@freelists.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> RE: Query started getting
1722 error - interesting explanation why</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>Jay,</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;&nbsp;&nbsp; </span></font><font size=2
color=blue face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:blue'>Did that varchar2 have numbers only in it before it stopped working
and then picked up one with an alpha character?&nbsp; I've seen that one more
than I care to remember.</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<div class=MsoNormal align=center style='margin-left:.5in;text-align:center'><font
size=3 face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center>

</span></font></div>

<p class=MsoNormal style='margin-right:0in;margin-bottom:12.0pt;margin-left:
.5in'><b><font size=2 face=Tahoma><span style='font-size:10.0pt;font-family:
Tahoma;font-weight:bold'>From:</span></font></b><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'> oracle-l-bounce@freelists.org
[mailto:oracle-l-bounce@freelists.org] <b><span style='font-weight:bold'>On
Behalf Of </span></b>JayMiller@TDWaterhouse.com<br>
<b><span style='font-weight:bold'>Sent:</span></b> Friday, September 09, 2005
2:16 PM<br>
<b><span style='font-weight:bold'>To:</span></b> oracle-l@freelists.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> Query started getting
1722 error - interesting explanation why</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>I got a call from a developer
the other week complaining that a query in QA had started giving an
ora-1722.&nbsp; It had worked fine for several months and the identical query
was working fine in production.</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>Select count(1) </span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>from prod.job_profile jp</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>where step_id &lt; 9999</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>and not exists (select
'x' from prod.job_log jl</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
where jl.job_id = jp.job_id</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
and ( jl.status in ('C', 'EI') )</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
and&nbsp; jl.batch_id in (select to_number(text_value)</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from prod.batch_parameter</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
where name = 'BATCH_ID'));</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>Investigating confirmed
this, along with the fact that the query was comparing a string (jl.batch_id)
with a number (to_number(text_value)).&nbsp; But why did it suddenly stop working
and why did it still work in production?</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>Comparing explain plans
between QA and production I saw that they were different (statistics had
changed during QA testing).&nbsp; The query that failed was using an index on
jl.batch_id.&nbsp; </span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>Apparently Oracle automatically
took care of converting the string to a number *unless* the number was being
used to access an index on the varchar2 column.&nbsp; Interesting
behavior.&nbsp; I can see why it might work that way but it's certainly not
intuitive. </span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>Of course explaining this
to the developer took quite a while.&nbsp; &quot;It worked before, why
shouldn't it work now?&nbsp; What's wrong with Oracle?&quot;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>Oracle 9.2.0.6</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<div>

<p class=MsoAutoSig style='margin-left:.5in'><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>Jay
Miller</span></font></p>

<p class=MsoAutoSig style='margin-left:.5in'><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>Sr.
Oracle DBA</span></font></p>

</div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<div>

<p class=MsoNormal style='margin-left:1.0in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>.</span></font></p>

</div>

<div class=MsoNormal align=center style='margin-left:.5in;text-align:center'><font
size=3 face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=1 width="100%" align=center>

</span></font></div>

<p style='margin-left:.5in'><strong><b><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>This message is confidential and sent by TD Waterhouse
solely for use</span></font></b></strong><b><span style='font-weight:bold'><br>
<strong><b><font face="Times New Roman">by the intended recipient. If you are
not the intended recipient, you</font></b></strong><br>
<strong><b><font face="Times New Roman">are hereby notified that any use,
distribution or copying of this</font></b></strong><br>
<strong><b><font face="Times New Roman">communication is strictly prohibited.
This should not be deemed as an</font></b></strong><br>
<strong><b><font face="Times New Roman">offer or solicitation, to buy or sell
any product. Any 3rd party</font></b></strong><br>
<strong><b><font face="Times New Roman">information contained herein was
prepared by sources deemed reliable,</font></b></strong><br>
<strong><b><font face="Times New Roman">but is not guaranteed. TD Waterhouse
does not accept electronic</font></b></strong><br>
<strong><b><font face="Times New Roman">instructions that would require an
original signature. Information</font></b></strong><br>
<strong><b><font face="Times New Roman">received by or sent from TD Waterhouse
is stored, subject to review,</font></b></strong><br>
<strong><b><font face="Times New Roman">and may be produced to regulatory
authorities or others with a legal</font></b></strong><br>
<strong><b><font face="Times New Roman">right to such. </font></b></strong></span></b></p>

</div>

</body>

</html>

------_=_NextPart_001_01C5B56C.62D1DEB0--
--
http://www.freelists.org/webpage/oracle-l

