Help!!!!
I have a column that is like char, and I need to turn it to number, but I have characters in this field as I do to remove them.
For in my SELECT I need to compare this field with that of another table.
Doubt function to_number
-
- Rank: Estagiário Pleno
- Posts: 4
- Joined: Wed, 30 Apr 2008 3:12 pm
- Location: São Paulo
Mônica F.
I will explain better ....
I have to compare the Num_nf (Number) field of a table with the Num_doc_origem (ChAR) field of another table. However, as the num_doc_origem column was like char, she accepted the insertion of data that should not, as incredible as it seems had a user who inserted email information instead of putting the note number. That's why I can not turn the field into number.
presents the error: ORA-01722: invalid number
I really need help !!!
Thanks!
Monica F.
I have to compare the Num_nf (Number) field of a table with the Num_doc_origem (ChAR) field of another table. However, as the num_doc_origem column was like char, she accepted the insertion of data that should not, as incredible as it seems had a user who inserted email information instead of putting the note number. That's why I can not turn the field into number.
presents the error: ORA-01722: invalid number
I really need help !!!
Thanks!
Monica F.
vixiiiii ... I think you will have to sweep what the note is wrong ... to arrange her first and then do this alter
if you do not want to do this not to give error in your Function You can tmb instead of transforming the char to number transform the number to char ...
Trim (field_char) = trim (to_char (field_number))
]
see if it serves you ...
Abrçs
if you do not want to do this not to give error in your Function You can tmb instead of transforming the char to number transform the number to char ...
Trim (field_char) = trim (to_char (field_number))
]
see if it serves you ...
Abrçs
-
- Moderador
- Posts: 2016
- Joined: Wed, 12 Jan 2005 3:25 pm
- Location: Araraquara - SP
Abraço,
Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP
Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP
Mônica,
a tip to fetch these notes at the base, would be test whether it is Number and if not, play in a log table or, concatenate the error.
In this example below, you will fall into others as there is a letter in the field.
Whatever, send it there.
a tip to fetch these notes at the base, would be test whether it is Number and if not, play in a log table or, concatenate the error.
In this example below, you will fall into others as there is a letter in the field.
DECLARE
VNUMBER NUMBER;
BEGIN
SELECT TO_NUMBER(NRO_SEQ)
INTO VNUMBER
FROM TESTE
WHERE ID_PAC = 1
AND ID_CONS = 2;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(' Não é Number.');
END;
CREATE OR REPLACE FUNCTION Retorna_Numericos(v_string IN CHAR)
RETURN CHAR
IS
BEGIN
RETURN REPLACE(TRANSLATE(v_string,
TRANSLATE(v_string, '0123456789', ' ') ,
LPAD(' ', LENGTH(v_string), ' ')
), ' ', '');
END;
___________
Thiago Vetis: -O
-
- Information
-
Who is online
Users browsing this forum: No registered users and 9 guests