I have searched for and seen some similar questions, but none have solved my problem. I am getting a invalid number error on my TO_NUMBER in my where clause. Some things I have read said that it can be caused by where you place the TO_NUMBER in your where clause, so I was hoping someone could help me solve this. Here is the where clause in my query:
WHERE year_sec = TEST.YEAR_SEC_BY_DATE ('F', 0)
AND (year_sec = '2014F')
AND ((no_name LIKE '54%' AND user3 IS NOT NULL)
OR (SUBSTR (no_name, 1, 2) = '52' AND SUBSTR (no_name, 5, 1) = '8')
OR (no_name LIKE '56%'))
OR (TO_NUMBER(SUBSTR(year_sec,1,4), '9999') >= 2015)
AND ((no_name LIKE '543%' AND user3 IS NOT NULL)
OR (no_name LIKE '523%')
OR (no_name LIKE '563%'));
year_sec is always 4 digits with one letter after, and never null (if it isn't then there would be much bigger problems). So can anyone see why this would be causing the ORA-01722 error?
EDIT: Removed quotes, error while copying over sql.
SUBSTR(year_sec,1,4)is always a number? What is the result ofselect SUBSTR(year_sec,1,4) from ... where SUBSTR(year_sec,1,1) NOT BETWEEN '0' AND '9' OR SUBSTR(year_sec,2,1) NOT BETWEEN '0' AND '9' OR ...for all four positions - Lennart