I know Oracle (I am working on Oracle11gR2) can convert data-types into each other implicitly if it is able to do so. For example if I try to insert a number into varchar area, it implicitly converts number into a varchar or vice versa a varchar would be converted into a number if it is a valid number.
Also Oracle does this implicit conversion on joins. If I join a number column to a varchar column, it will implicitly convert the varchar into number and complete the query. But if there is any invalid numbers in the varchar column it would throw an ORA-01722 : Invalid Number
You can see this setting by running the codes below:
create table test_1(
id varchar2(20),
val number);
create table test_2(
id number,
name varchar2(20)
);
insert into test_1 values ('abc', 10);
insert into test_1 values ('1', 11);
insert into test_2 values (1,'abc');
insert into test_2 values (2,'def');
-- Throw error
select
*
from
test_1, test_2
where
test_1.id = test_2.id
-- work
select
test_1.id, val, name
from
test_1, test_2
where
test_1.id = test_2.id
and test_1.id = '1'
You can also see and run the samples on : http://sqlfiddle.com/#!4/fdce3/9/0
Now my question, is there any option or configuration parameter to force Oracle to make this implicit conversion into varchar instead of number? Or exactly see the source of error of invalid number (which column or which join)?
I know that I can explicitly do the conversion to avoid error. Like below, but I do not want that as solution.
select
*
from
test_1, test_2
where
test_1.id = to_char(test_2.id)
You can visit also http://sqlfiddle.com/#!4/fdce3/10 to see the code above works properly.
Thanks