<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Eddie Awad’s Blog - Latest Comments in NVL, NVL2 or COALESCE?</title><link>http://awads.disqus.com/</link><description>News, views, tips and tricks on Oracle and other fun stuff</description><atom:link href="https://awads.disqus.com/nvl_nvl2_or_coalesce/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Fri, 06 Oct 2006 00:59:15 -0000</lastBuildDate><item><title>Re: NVL, NVL2 or COALESCE?</title><link>http://awads.net/wp/2006/01/27/nvl-nvl2-or-coalesce/#comment-3658307</link><description>&lt;p&gt;No, nvl is not limited to select statements.&lt;br&gt;For example: insert into t (comm) values (nvl(mycomm, 0))&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eddie Awad</dc:creator><pubDate>Fri, 06 Oct 2006 00:59:15 -0000</pubDate></item><item><title>Re: NVL, NVL2 or COALESCE?</title><link>http://awads.net/wp/2006/01/27/nvl-nvl2-or-coalesce/#comment-3658306</link><description>&lt;p&gt;how to use nvl function and insert statement together... or... usage of nvl is limited to select statements.. please help&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">sumanth</dc:creator><pubDate>Fri, 29 Sep 2006 02:47:41 -0000</pubDate></item><item><title>Re: NVL, NVL2 or COALESCE?</title><link>http://awads.net/wp/2006/01/27/nvl-nvl2-or-coalesce/#comment-3658305</link><description>&lt;p&gt;In certain situations in &lt;b&gt;8i&lt;/b&gt;, COALESCE did not behave the same as NVL, in fact it errored out. An example:&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;pre&gt;user@8i&amp;gt; create table t (id int, f blob)&lt;br&gt;  2  /&lt;br&gt;&lt;br&gt;Table created.&lt;br&gt;&lt;br&gt;user@8i&amp;gt; insert into t (id) values (1)&lt;br&gt;  2  /&lt;br&gt;&lt;br&gt;1 row created.&lt;br&gt;&lt;br&gt;user@8i&amp;gt; select&lt;br&gt;  2      id&lt;br&gt;  3      ,dbms_lob.getlength(f)&lt;br&gt;  4      ,nvl(dbms_lob.getlength(f),0)&lt;br&gt;  5  from t&lt;br&gt;  6  /&lt;br&gt;&lt;br&gt;        ID DBMS_LOB.GETLENGTH(F) NVL(DBMS_LOB.GETLENGTH(F),0)&lt;br&gt;---------- --------------------- ----------------------------&lt;br&gt;         1                                                  0&lt;br&gt;&lt;br&gt;user@8i&amp;gt; select&lt;br&gt;  2      id&lt;br&gt;  3      ,dbms_lob.getlength(f)&lt;br&gt;  4      ,coalesce(dbms_lob.getlength(f),0)&lt;br&gt;  5  from t&lt;br&gt;  6  /&lt;br&gt;    ,coalesce(dbms_lob.getlength(f),0)&lt;br&gt;     *&lt;br&gt;ERROR at line 4:&lt;br&gt;ORA-00904: invalid column name&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;The above worked in 9i (and XE)&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;pre&gt;user@9i&amp;gt; create table t (id int, f blob)&lt;br&gt;  2  /&lt;br&gt;&lt;br&gt;Table created.&lt;br&gt;&lt;br&gt;user@9i&amp;gt; insert into t (id) values (1)&lt;br&gt;  2  /&lt;br&gt;&lt;br&gt;1 row created.&lt;br&gt;&lt;br&gt;user@9i&amp;gt; select&lt;br&gt;  2      id&lt;br&gt;  3      ,dbms_lob.getlength(f)&lt;br&gt;  4      ,nvl(dbms_lob.getlength(f),0)&lt;br&gt;  5  from t&lt;br&gt;  6  /&lt;br&gt;&lt;br&gt;        ID DBMS_LOB.GETLENGTH(F) NVL(DBMS_LOB.GETLENGTH(F),0)&lt;br&gt;---------- --------------------- ----------------------------&lt;br&gt;         1                                                  0&lt;br&gt;&lt;br&gt;user@9i&amp;gt; select&lt;br&gt;  2      id&lt;br&gt;  3      ,dbms_lob.getlength(f)&lt;br&gt;  4      ,coalesce(dbms_lob.getlength(f),0)&lt;br&gt;  5  from t&lt;br&gt;  6  /&lt;br&gt;&lt;br&gt;        ID DBMS_LOB.GETLENGTH(F) COALESCE(DBMS_LOB.GETLENGTH(F),0)&lt;br&gt;---------- --------------------- ---------------------------------&lt;br&gt;         1                                                       0&lt;br&gt;&lt;br&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eddie Awad</dc:creator><pubDate>Fri, 27 Jan 2006 18:46:10 -0000</pubDate></item><item><title>Re: NVL, NVL2 or COALESCE?</title><link>http://awads.net/wp/2006/01/27/nvl-nvl2-or-coalesce/#comment-3658301</link><description>&lt;p&gt;Robert,&lt;br&gt;I think that the difference in perf mentionned on donald's site (oracledba) is mostly due to the operations used in the tests other than the first one (e.g. nvl(c,to_date('0001','yyyy')) != nvl(d,to_date('0001','yyyy')) where the to_date costs a lot). If you workaround these, then the timing differences are much less important.&lt;br&gt;rgds&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">gsalem</dc:creator><pubDate>Fri, 27 Jan 2006 17:53:03 -0000</pubDate></item><item><title>Re: NVL, NVL2 or COALESCE?</title><link>http://awads.net/wp/2006/01/27/nvl-nvl2-or-coalesce/#comment-3658300</link><description>&lt;p&gt;I believe this is the article to which David is referring:&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.oracledba.co.uk/tips/plsql_nvl_costs.htm" rel="nofollow noopener" target="_blank" title="http://www.oracledba.co.uk/tips/plsql_nvl_costs.htm"&gt;http://www.oracledba.co.uk/...&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;I remember there being another, but I can't find it.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;For the record, I use coalesce in Sybase, but in Oracle that's the one I don't use.  Don't know why.  Probably DECODE is the one I use the most.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Robert Vollman</dc:creator><pubDate>Fri, 27 Jan 2006 17:16:52 -0000</pubDate></item><item><title>Re: NVL, NVL2 or COALESCE?</title><link>http://awads.net/wp/2006/01/27/nvl-nvl2-or-coalesce/#comment-3658304</link><description>&lt;p&gt;I remember reading recently (on Ask Tom I believe) that Nvl() has the disadvantage that expr2 is always evaluated even when expr1 is not null, which can be expensive if expr2 is non-trivial -- a PL/SQL function call for example.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;That makes Coalesce the winner for me.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">David Aldridge</dc:creator><pubDate>Fri, 27 Jan 2006 12:12:20 -0000</pubDate></item><item><title>Re: NVL, NVL2 or COALESCE?</title><link>http://awads.net/wp/2006/01/27/nvl-nvl2-or-coalesce/#comment-3658303</link><description>&lt;p&gt;Hey guys!&lt;br&gt;be honest - i don not beleave that 60% used coalesce?&lt;br&gt;i always used nvl- the classic NULL -killer :-)&lt;br&gt;Karl&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Karl</dc:creator><pubDate>Fri, 27 Jan 2006 10:51:07 -0000</pubDate></item><item><title>Re: NVL, NVL2 or COALESCE?</title><link>http://awads.net/wp/2006/01/27/nvl-nvl2-or-coalesce/#comment-3658302</link><description>&lt;p&gt;(maybe more?)&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;select decode(x,0,null,x) from t;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;is&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;select nullif(x,0) from t;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Laurent Schneider</dc:creator><pubDate>Fri, 27 Jan 2006 10:20:07 -0000</pubDate></item></channel></rss>