?
Solved

ORA-01722: invalid number

Posted on 2011-02-14
11
Medium Priority
?
1,129 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 2000 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

719 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