Search code examples
sqloracle-databaseora-01722

PL SQL : NVL first parameter type conversion issue


I have a table Application which has a column

BORROWINGTERM   NUMBER(10,0) Nullable

why this script throw an error (ORA-01722 invalid number)

select nvl(borrowingterm, 'no term') from Application 

while this one works

select nvl(to_char(borrowingterm), 'no term') from Application 

and this one also works

select nvl(1234,5678) from dual; 

base on this article

the first parameter of NVL function should be string type


Solution

  • You're getting the error because you are mixing two different types in the nvl clause. One number, one string. The types must be the same.