RE: NVL function with arguments of different data types

  • From: "Harel Safra" <harel.safra@xxxxxxxxx>
  • To: <fzziwa@xxxxxxxxx>, <oracle-l@xxxxxxxxxxxxx>
  • Date: Mon, 5 Jul 2010 00:15:42 +0300

First result on google for the search string "oracle nvl data types" gives
us the NVL page from the documentation that states:

The arguments expr1 and expr2 can have any datatype. If their datatypes are
different, then Oracle Database implicitly converts one to the other. If
they are cannot be converted implicitly, the database returns an error. The
implicit conversion is implemented as follows:

.         If expr1 is character data, then Oracle Database converts expr2 to
the datatype of expr1 before comparing them and returns VARCHAR2 in the
character set of expr1.

.         If expr1 is numeric, then Oracle determines which argument has the
highest numeric precedence, implicitly converts the other argument to that
datatype, and returns that datatype.

See Also:

Table 2-10,
<http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements
002.htm#g195937> "Implicit Type Conversion Matrix" for more information on
implicit conversion and
<http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements
001.htm#i156865> "Numeric Precedence" for information on numeric precedence

Harel Safra

 

From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx]
On Behalf Of francis zziwa
Sent: Sunday, July 04, 2010 11:46 PM
To: oracle-l@xxxxxxxxxxxxx
Subject: NVL function with arguments of different data types

 

Hi listmates,

Is the NVL  function applicable when the arguments supplied are of different
types. e.g nvl(x1,x2) where x1 is an integer and x2 is a character.

And in a situation where one of the arguments cannot be converted to another
type.

Any help will be appreciated.


~~~~~~~~~~
regards,
Francis

Other related posts: