Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

What happened to nvl2(fdate, sysdate-fdate, sysdate)

MorvenApr 17 2012 — edited Oct 28 2012
Hi guys,

Oracle 11.2

I just found this by chance:
SQL> create table tab_0417(fid number, fdate date);

Table created

SQL> insert into tab_0417 values(1, date'2012-01-01');

1 row inserted

SQL> insert into tab_0417 values(1, NULL);

1 row inserted

SQL> commit;

Commit complete

SQL> select fid, fdate, nvl2(fdate, sysdate-fdate, sysdate) from tab_0417;

       FID FDATE       NVL2(FDATE,SYSDATE-FDATE,SYSDA
---------- ----------- ------------------------------
         1 1/1/2012                  107.580358796296
         1                            2456035.5803588
I expected an exception since the second and the third parameter of NVL2 have different data types and cannot be converted implicitly. But it executed successfully, and got a strange number 2456035.5803588, could anyone explain it?

Thanks in advance.
This post has been answered by 908002 on Apr 17 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 25 2012
Added on Apr 17 2012
13 comments
947 views