PL SQL : NVL first parameter type conversion issue

nandin picture nandin · Mar 1, 2011 · Viewed 14.1k times · Source

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

Answer

Lost in Alabama picture Lost in Alabama · Mar 1, 2011

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.