Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ORA-01722: invalid number

Posted on 2011-02-14
11
Medium Priority
?
1,150 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 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
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Suggested Courses

916 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