Solved

ORA-01722: invalid number

Posted on 2011-02-14
11
1,110 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
  • 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 142

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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 142

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 142

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
case statement in where clause 5 48
SQL query question 8 75
Distinct values from all columns in a table?? PL SQL 4 37
migration MS SQL database to Oracle 30 61
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
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

770 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