<?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 Cool Undocumented SQL Function SYS_OP_MAP_NONNULL and Some Alternatives</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/cool_undocumented_sql_function_sys_op_map_nonnull_and_some_alternatives/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 06 Dec 2007 11:26:57 -0000</lastBuildDate><item><title>Re: Cool Undocumented SQL Function SYS_OP_MAP_NONNULL and Some Alternatives</title><link>http://awads.net/wp/2006/09/19/cool-undocumented-sql-function-sys_op_map_nonnull-and-some-alternatives/#comment-3658807</link><description>&lt;p&gt;I tried &lt;br&gt;&lt;/p&gt;&lt;pre&gt;select * from dual where sys_op_map_nonnull(null) = 'FF' ;&lt;br&gt;D&lt;br&gt;-&lt;br&gt;X&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;br&gt;It does return a row on my 10.2.0.3&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Laurent Schneider</dc:creator><pubDate>Thu, 06 Dec 2007 11:26:57 -0000</pubDate></item><item><title>Re: Cool Undocumented SQL Function SYS_OP_MAP_NONNULL and Some Alternatives</title><link>http://awads.net/wp/2006/09/19/cool-undocumented-sql-function-sys_op_map_nonnull-and-some-alternatives/#comment-3658806</link><description>&lt;p&gt;Whoa.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Am I confused?&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;I thought sys_op_map_nonnull('any non-null value') was supposed be 'any non-null value'.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;I can also guarantee to you that&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;pre&gt;select *&lt;br&gt;from dual&lt;br&gt;where sys_op_map_nonnull(null) = 'FF'&lt;/pre&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;returns a row.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Now I think it's doing something more subtle - it's doing a mapping of anything you put in it so&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;pre&gt;select *&lt;br&gt;from dual&lt;br&gt;where sys_op_map_nonnull(null) = sys_op_map_nonnull('FF')&lt;/pre&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;will not return a row... need to test.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Michael Friedman</dc:creator><pubDate>Mon, 25 Sep 2006 21:18:47 -0000</pubDate></item><item><title>Re: Cool Undocumented SQL Function SYS_OP_MAP_NONNULL and Some Alternatives</title><link>http://awads.net/wp/2006/09/19/cool-undocumented-sql-function-sys_op_map_nonnull-and-some-alternatives/#comment-3658805</link><description>&lt;p&gt;Jonathan, thanks for clarifying the subtlety of sys_op_map_nonnull.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Here is a quick test that I think demonstrates Michael's point that sys_op_map_nonnull (col1) is the same as nvl(col1,'FF'):&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;  EDDIE@XE&amp;gt; CREATE TABLE t (&lt;br&gt;    2   col1  VARCHAR2(10),&lt;br&gt;    3   col2  VARCHAR2(10));&lt;br&gt;&lt;br&gt;  Table created.&lt;br&gt;&lt;br&gt;  EDDIE@XE&amp;gt; INSERT INTO t&lt;br&gt;    2       VALUES (NULL,&lt;br&gt;    3               NULL&lt;br&gt;    4              )&lt;br&gt;    5  /&lt;br&gt;&lt;br&gt;  1 row created.&lt;br&gt;&lt;br&gt;  EDDIE@XE&amp;gt; INSERT INTO t&lt;br&gt;    2       VALUES ('FF',&lt;br&gt;    3               'FF'&lt;br&gt;    4              )&lt;br&gt;    5  /&lt;br&gt;&lt;br&gt;  1 row created.&lt;br&gt;&lt;br&gt;  EDDIE@XE&amp;gt; INSERT INTO t&lt;br&gt;    2       VALUES ('Eddie',&lt;br&gt;    3               'Awad'&lt;br&gt;    4              )&lt;br&gt;    5  /&lt;br&gt;&lt;br&gt;  1 row created.&lt;br&gt;&lt;br&gt;  EDDIE@XE&amp;gt; SELECT NVL (col1, 'I am null') col1,&lt;br&gt;    2         NVL (col2, 'I am null') col2&lt;br&gt;    3    FROM t&lt;br&gt;    4   WHERE nvl(col1,'FF') = nvl(col2,'FF')&lt;br&gt;    5  /&lt;br&gt;&lt;br&gt;  COL1       COL2&lt;br&gt;  ---------- ----------&lt;br&gt;  I am null  I am null&lt;br&gt;  FF         FF&lt;br&gt;&lt;br&gt;  EDDIE@XE&amp;gt; SELECT NVL (col1, 'I am null') col1,&lt;br&gt;    2         NVL (col2, 'I am null') col2&lt;br&gt;    3    FROM t&lt;br&gt;    4   WHERE sys_op_map_nonnull (col1) = sys_op_map_nonnull (col2)&lt;br&gt;    5  /&lt;br&gt;&lt;br&gt;  COL1       COL2&lt;br&gt;  ---------- ----------&lt;br&gt;  I am null  I am null&lt;br&gt;  FF         FF&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;So, if sys_op_map_nonnull (col1) did not act like nvl(col2,'FF'), Oracle would not return the row with the varchar2 value FF in both col1 and col2.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;I think the explanation here is that sys_op_map_nonnull ('FF') equals sys_op_map_nonnull ('FF') but sys_op_map_nonnull ('FF') does not equal 'FF':&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;  EDDIE@XE&amp;gt; SELECT *&lt;br&gt;    2  FROM dual&lt;br&gt;    3  where  sys_op_map_nonnull ('FF') = sys_op_map_nonnull ('FF')&lt;br&gt;    4  /&lt;br&gt;&lt;br&gt;  D&lt;br&gt;  -&lt;br&gt;  X&lt;br&gt;&lt;br&gt;  EDDIE@XE&amp;gt; SELECT *&lt;br&gt;    2  FROM dual&lt;br&gt;    3  where  sys_op_map_nonnull ('FF') = 'FF'&lt;br&gt;    4  /&lt;br&gt;&lt;br&gt;  no rows selected&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eddie Awad</dc:creator><pubDate>Mon, 25 Sep 2006 20:16:05 -0000</pubDate></item><item><title>Re: Cool Undocumented SQL Function SYS_OP_MAP_NONNULL and Some Alternatives</title><link>http://awads.net/wp/2006/09/19/cool-undocumented-sql-function-sys_op_map_nonnull-and-some-alternatives/#comment-3658804</link><description>&lt;p&gt;sys_op_map_nonnull() is a little more subtle than nvl(x,'0xff').&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;The thing it maps to is an internally stored FF, and I don't think you can get this actual value stored for any type except RAW.  Then, to deal with the problem of comparing raws when using sys_op_mapnonnull(), sys_op_mapnonnull(ff) returns a two-byte value which is 00ff, so sys_op_map_nonnull(ff) != ff.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jonathan Lewis</dc:creator><pubDate>Mon, 25 Sep 2006 17:48:18 -0000</pubDate></item><item><title>Re: Cool Undocumented SQL Function SYS_OP_MAP_NONNULL and Some Alternatives</title><link>http://awads.net/wp/2006/09/19/cool-undocumented-sql-function-sys_op_map_nonnull-and-some-alternatives/#comment-3658803</link><description>&lt;p&gt;Michael, I guess you have just found out why it's not documented. There are many other ways to compare two nulls, so there is really no need to use sys_op_map_nonnull. However, I will always be interested in the "undocumented", just to satisfy my curiosity.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eddie Awad</dc:creator><pubDate>Wed, 20 Sep 2006 12:39:16 -0000</pubDate></item><item><title>Re: Cool Undocumented SQL Function SYS_OP_MAP_NONNULL and Some Alternatives</title><link>http://awads.net/wp/2006/09/19/cool-undocumented-sql-function-sys_op_map_nonnull-and-some-alternatives/#comment-3658802</link><description>&lt;p&gt;This would be a lot more interesting if it did not just act like nvl(x,'FF').  What's the point?  You could have FF in your data.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Michael Friedman</dc:creator><pubDate>Wed, 20 Sep 2006 08:02:04 -0000</pubDate></item><item><title>Re: Cool Undocumented SQL Function SYS_OP_MAP_NONNULL and Some Alternatives</title><link>http://awads.net/wp/2006/09/19/cool-undocumented-sql-function-sys_op_map_nonnull-and-some-alternatives/#comment-3658801</link><description>&lt;p&gt;Thanks for the extra tip Pete.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eddie Awad</dc:creator><pubDate>Wed, 20 Sep 2006 00:29:56 -0000</pubDate></item><item><title>Re: Cool Undocumented SQL Function SYS_OP_MAP_NONNULL and Some Alternatives</title><link>http://awads.net/wp/2006/09/19/cool-undocumented-sql-function-sys_op_map_nonnull-and-some-alternatives/#comment-3658800</link><description>&lt;p&gt;Oracle uses this function in the 'default' index on materialized views for fast refresh - which in the case of DW Mviews is a little odd as I would not expect NULLS in my fact summaries!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Pete_s</dc:creator><pubDate>Tue, 19 Sep 2006 11:46:46 -0000</pubDate></item></channel></rss>