954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ERROR at line 1: ORA-01722: invalid number

Hi,

I have this view:

DROP VIEW digits;

CREATE VIEW digits
AS
(
    SELECT 
        TO_NUMBER(SUBSTR(rounded_cost, 1, INSTR(rounded_cost, '.' -1))) left_digits,
        TO_NUMBER(SUBSTR(rounded_cost, INSTR(rounded_cost, '.' + 1, LENGTH(rounded_cost)))) right_digits
    FROM roundcost
);


It allows me to create it but the values stored are apparently not valid numbers. When I try select * from digits I get
"ERROR at line 1: ORA-01722: invalid number ".

The roundcost table has numbers like 6.71, 3.54, etc.

Any ideas?

Thanks,

Roy

Roybut
Light Poster
26 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

INSTR(rounded_cost, '.' -1)

what does the above part do ?

debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 

what is the result of your substr you need

janki066
Newbie Poster
3 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

SELECT
TO_NUMBER(SUBSTR(6.45, 1, INSTR(6.45, '.', 1))) left_digits,
TO_NUMBER(SUBSTR(6.45, INSTR(6.45, '.', - 1))) right_digits from dual

instead of 6.45 user your roundcost.

result will be 6 for left digit
and .45 for right digit

janki066
Newbie Poster
3 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

What values does this rounded_cost attribute consists of?

naziatarannum
Junior Poster in Training
51 posts since Jul 2009
Reputation Points: 9
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You