Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Re[2]: to_number question

Re: Re[2]: to_number question

From: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Sat, 17 Jul 2004 13:09:45 +0100
Message-ID: <01c301c46bf6$f4cf2700$7102a8c0@Primary>

Think about this one:

create table t1 (

    v1 varchar2(1),
    v2 varchar2(1)
);

insert into t1 values (1,'a');
insert into t1 values ('a',1);
insert into t1 values(2,2);

commit;

select *
from t1
where

        to_number(v1) = 2
and to_number(v2) = 2
;

If you handled the first two rows differently from each other (which, in effect, is what relational theory says you should do - since column ordering is not supposed to be significant), you can get the right result set. But there is no current mechanism in Oracle that could find it.

>From the relational point of view, the answer to this 'problem' is easy. You've made a mistake in your analysis and got the column domain wrong - you need a domain which includes numbers and characters and includes a "to_number" function that has meaning when applied to a character-like object in that domain.

Regards

Jonathan Lewis

http://www.jlcomp.demon.co.uk/faq/ind_faq.html The Co-operative Oracle Users' FAQ

http://www.jlcomp.demon.co.uk/seminar.html Optimising Oracle Seminar - schedule updated July 14th

Well put Stephen. I agree with your post.

SLDC> The comments were an expression of disbelief (not lack
SLDC> of understanding) that the specifications concerning
SLDC> subqueries would be so loose and open ended as to
SLDC> allow this level of unpredictability.

Yes. And there's a lot more to this issue than just the specific Oracle behavior we've been talking about. I have many questions, most of which I'll just have to research off-list. For example:

Now that I see what Oracle is doing in this one case, I want to go deeper, find out about the intent (of theorists, language designers, optimizer writers), come up with a mental model that encompasses the behavior we've seen, and so forth. There's a lot of drilling down to be done here, and probably a good article to be written afterward.

Best regards,

Jonathan Gennick --- Brighten the corner where you are



Please see the official ORACLE-L FAQ: http://www.orafaq.com

To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
Received on Sat Jul 17 2004 - 07:06:21 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US