Solved

ORA-01722: invalid number

Posted on 2011-02-14
11
1,115 Views
Last Modified: 2012-05-11
Hello,

How can I resolve this problem?

SQL> select to_char(DAT,'YYYY MON DD HH24:MI:SS') datetime, sum(to_number(R_RPS)) R_RPS, sum(to_number(W_WPS)) W_WPS,
  2    sum(to_number(Q_SQFULL)) SQLFULL
  3  from TMP__IO
  4  group by to_char(DAT,'YYYY MON DD HH24:MI:SS') ;
select to_char(DAT,'YYYY MON DD HH24:MI:SS') datetime, sum(to_number(R_RPS)) R_RPS, sum(to_number(W_WPS)) W_WPS,
                                                                                                         *
ERREUR Ó la ligne 1 :
ORA-01722: invalid number

Thanks

bibi
0
Comment
Question by:bibi92
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
11 Comments
 
LVL 12

Expert Comment

by:enachemc
ID: 34887127
make sure that all the values in that column are realy number (no spaces and no other characters)
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 34887149
I cnform that at least 1 row has data that is not "to_number" ...

I use this function to "help" me find the culprit:
create or replace
FUNCTION GetNumber2(txt_IN IN varchar2)
RETURN NUMBER
IS
	test NUMBER;
	res VARCHAR2(128);
BEGIN

BEGIN
  res := TRANSLATE ( txt_IN, '0123456789' , '          ');
  res := REPLACE( TRANSLATE ( txt_IN, res ,  ' ' ) , ' ', '');

  test := TO_NUMBER(res);

EXCEPTION
  WHEN VALUE_ERROR THEN test:=NULL;
END;

RETURN (test);

END GetNumber2;

Open in new window

0
 

Author Comment

by:bibi92
ID: 34887401
values in the columns are varchar.

Thanks

bibi
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:enachemc
ID: 34887429
varchar yes, but they should contain only numbers stored as strings
0
 

Author Comment

by:bibi92
ID: 34887460
I have created the function but I have the same error.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 34887465
using the function, you can find the problem:

select * from yourtable
where GetNumber2(yourfield) <> yourfield

Open in new window

0
 

Author Comment

by:bibi92
ID: 34887539
SQL> select * from TMP__IO

  2  where GetNumber2(R_RPS) <> R_RPS
  3  /
where GetNumber2(R_RPS) <> R_RPS
                           *
ERREUR Ó la ligne 2 :
ORA-01722: invalid number

Thanks

bibi
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 34887572
sorry:
select * from TMP__IO
  where GetNumber2(R_RPS) IS NULL

Open in new window

0
 
LVL 12

Expert Comment

by:enachemc
ID: 34887576
select * from TMP__IO where not regexp_like(R_RPS, '[[:digit:]]+')
0
 

Author Comment

by:bibi92
ID: 34887627

SQL> select * from TMP__IO

  2  where GetNumber2(R_RPS) is null
  3  /
no row
0
 

Author Closing Comment

by:bibi92
ID: 34889780
Thanks bibi
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question