Home:ALL Converter>Oracle equivalent of NVL for number datatype

Oracle equivalent of NVL for number datatype

Ask Time:2014-09-18T21:28:20         Author:b00kgrrl

Json Formatter

What is the Oracle equivalent of NVL for number datatypes?

This works since the datatype is VARCHAR:

    select nvl(enrol.OUAC_APPLNO, 'blank') Invalid_OUAC_APPLNO

But this doesn't work since the datatype is NUMBER:

    select nvl(enrol.ouac_type_id, 'blank') REGTYP

Author:b00kgrrl,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/25914062/oracle-equivalent-of-nvl-for-number-datatype
Ben :

There is no equivalent and no Oracle functions will accept this (apart from DECODE() but don't do that); you're going to have to convert your number to a character:\n\nselect nvl(cast(enrol.OUAC_APPLNO as varchar2(10)), 'blank') \n\n\nYou may need to change the number of characters you're converting to as appropriate.\n\nHowever, I don't know why you're doing this at all. By definition a NULL implies non-existence. If you want to display blank in order to confer non-existence this is something that you should be doing with your presentation layer rather than the database.",
2014-09-18T13:32:50
dursun :

it wont work because oracle wants every row should be in the same type otherwise you cannot run functions on that column, you have cast ouac_type_id to be varchar as below;\n\nselect nvl(cast(enrol.OUAC_APPLNO as varchar2(10)), 'blank') REGTYP\n",
2014-09-18T13:33:44
yy