Today I came accross with above two errors. These are two sets of errors
1. Parallel Query Failing
2. Invalid Comparision Operation.
Query Failing:
SQL> select owner,index_name,degree from dba_indexes where table_name in ('SALES_MASTER_HISTORY') order by INDEX_NAME;
1. Parallel Query Failing
2. Invalid Comparision Operation.
Query Failing:
SELECT COUNT(*) FROM SALES_MASTER_HISTORY WHERE TREASURYNUMBER < 20000;
ORA-12801: error signaled in parallel query server P001
ORA-01722: invalid number
When i check degree on this table it was set to 1 so no problem found there but degree with above table indexes was set to 4. I changed the degree to 1 to sort first issue as below:
SQL> SQL> select owner,table_name,degree from dba_tables where table_name in ('SALES_MASTER_HISTORY');
OWNER TABLE_NAME DEGREE
------------------------------ ------------------------------ ----------
CAP SALES_MASTER_HISTORY 1
------------------------------ ------------------------------ ----------
CAP SALES_MASTER_HISTORY 1
SQL> select index_name,degree from dba_indexes where table_name in ('SALES_MASTER_HISTORY');
INDEX_NAME DEGREE
------------------------------ ----------------------------------------
IDX_TMH_NETTEDBOOKINGREF 4
IDX_VALUEDATE 4
PK_TRADES_MASTER_HISTORY 4
IDX_TMH_CORESYSREF 4
IDX_TMH_TRUNC_BOOKEDDATE_IDX 4
IDX_TMH_BRANCH_CODE 4
IDX_TMH_CUSTOMER_NUMBER 4
IDX_TMH_BROKERCODE 4
IDX_BOOKEDDATE 4
IDX_TMH_CONTRACTNUMBER 4
IDX_TMH_CUSTOMER 4
------------------------------ ----------------------------------------
IDX_TMH_NETTEDBOOKINGREF 4
IDX_VALUEDATE 4
PK_TRADES_MASTER_HISTORY 4
IDX_TMH_CORESYSREF 4
IDX_TMH_TRUNC_BOOKEDDATE_IDX 4
IDX_TMH_BRANCH_CODE 4
IDX_TMH_CUSTOMER_NUMBER 4
IDX_TMH_BROKERCODE 4
IDX_BOOKEDDATE 4
IDX_TMH_CONTRACTNUMBER 4
IDX_TMH_CUSTOMER 4
11 rows selected.
SQL> alter index CAP.IDX_BOOKEDDATE parallel 1;
Index altered.
SQL> alter index CAP.IDX_TMH_BRANCH_CODE parallel 1;
Index altered.
SQL> alter index CAP.IDX_TMH_BROKERCODE parallel 1;
Index altered.
SQL> alter index CAP.IDX_TMH_CONTRACTNUMBER parallel 1;
Index altered.
SQL> alter index CAP.IDX_TMH_CUSTOMER_NUMBER parallel 1;
Index altered.
SQL> alter index CAP.IDX_TMH_NETTEDBOOKINGREF parallel 1;
Index altered.
SQL> alter index CAP.IDX_VALUEDATE parallel 1;
Index altered.
SQL> alter index CAP.PK_TRADES_MASTER_HISTORY parallel 1;
Index altered.
SQL> alter index CAP.IDX_TMH_TRUNC_BOOKEDDATE_IDX parallel 1;
Index altered.
SQL> select owner,index_name,degree from dba_indexes where table_name in ('SALES_MASTER_HISTORY') order by INDEX_NAME;
OWNER INDEX_NAME DEGREE
------------------------------ ------------------------------ ----------------------------------------
CAPFX IDX_BOOKEDDATE 1
CAPFX IDX_TMH_BRANCH_CODE 1
CAPFX IDX_TMH_BROKERCODE 1
CAPFX IDX_TMH_CONTRACTNUMBER 1
CAPFX IDX_TMH_CORESYSREF 1
CAPFX IDX_TMH_CUSTOMER 1
CAPFX IDX_TMH_CUSTOMER_NUMBER 1
CAPFX IDX_TMH_NETTEDBOOKINGREF 1
CAPFX IDX_TMH_TRUNC_BOOKEDDATE_IDX 1
CAPFX IDX_VALUEDATE 1
CAPFX PK_TRADES_MASTER_HISTORY 1
------------------------------ ------------------------------ ----------------------------------------
CAPFX IDX_BOOKEDDATE 1
CAPFX IDX_TMH_BRANCH_CODE 1
CAPFX IDX_TMH_BROKERCODE 1
CAPFX IDX_TMH_CONTRACTNUMBER 1
CAPFX IDX_TMH_CORESYSREF 1
CAPFX IDX_TMH_CUSTOMER 1
CAPFX IDX_TMH_CUSTOMER_NUMBER 1
CAPFX IDX_TMH_NETTEDBOOKINGREF 1
CAPFX IDX_TMH_TRUNC_BOOKEDDATE_IDX 1
CAPFX IDX_VALUEDATE 1
CAPFX PK_TRADES_MASTER_HISTORY 1
After that when i execute query it was giving just :
SQL> select count(*) FROM SALES_MASTER_HISTORY WHERE TREASURYNUMBER < 20000;
select count(*) FROM SALES_MASTER_HISTORY WHERE TREASURYNUMBER < 20000
*
ERROR at line 1:
ORA-01722: invalid number
select count(*) FROM SALES_MASTER_HISTORY WHERE TREASURYNUMBER < 20000
*
ERROR at line 1:
ORA-01722: invalid number
This is not really a database problem, here problem is TREASURYNUMBER is char(8) and when we compare it with number it causing implicit datatype conversion which causes error. This can be resolved by using 2000 value in quotes as below:
SQL> SELECT COUNT(*) FROM SALES_MASTER_HISTORY WHERE TREASURYNUMBER < '20000';
COUNT(*)
----------
109090909
----------
109090909
So, this is simple solution but beneficial to know.
Thanks for the post. I faced the same error. I'd never thought to_number can cause such an issue... Very helpful!
ReplyDeleteThank you, very useful for me plus I did the same step like you and I could fix it.
ReplyDeleteGood one
ReplyDelete