<p>Is there a performant equivalent to the isnull function for DB2?</p>

<p>Imagine some of our products are internal, so they don't have names:</p>

<pre><code>Select product.id, isnull(product.name, "Internal) 
From product
</code></pre>

<p>Might return:</p>

<pre><code>1 Socks 
2 Shoes 
3 Internal 
4 Pants
</code></pre>

[{'answer_id': 65111, 'author': 'Chris Shaffer', 'author_id': 6744, 'author_profile': 'https://Stackoverflow.com/users/6744', 'pm_score': 2, 'selected': False, 'text': '<p>I\'m not familiar with DB2, but have you tried COALESCE?</p>\n\n<p>ie:</p>\n\n<pre><code>\nSELECT Product.ID, COALESCE(product.Name, "Internal") AS ProductName\nFROM Product\n</code></pre>\n'}, {'answer_id': 163321, 'author': 'Fuangwith S.', 'author_id': 24550, 'author_profile': 'https://Stackoverflow.com/users/24550', 'pm_score': 0, 'selected': False, 'text': '<p><code>COALESCE</code> function same  <code>ISNULL</code> function\nNote. you must use <code>COALESCE</code> function with same data type of column that you check is null.</p>\n'}, {'answer_id': 256672, 'author': 'venkatram', 'author_id': 33392, 'author_profile': 'https://Stackoverflow.com/users/33392', 'pm_score': 0, 'selected': False, 'text': "<p>I think <code>COALESCE</code> function partially similar to the <code>isnull</code>, but try it.</p>\n\n<p>Why don't you go for null handling functions through application programs, it is better alternative. </p>\n"}, {'answer_id': 1122917, 'author': 'MadMurf', 'author_id': 46527, 'author_profile': 'https://Stackoverflow.com/users/46527', 'pm_score': 5, 'selected': False, 'text': '<p>For what its worth, COALESCE is similiar but </p>\n\n<pre><code>IFNULL(expr1, default)\n</code></pre>\n\n<p>is the exact match you\'re looking for in DB2. </p>\n\n<p>COALESCE allows multiple arguments, returning the first NON NULL expression, whereas IFNULL only permits the expression and the default.</p>\n\n<p>Thus</p>\n\n<pre><code>SELECT product.ID, IFNULL(product.Name, "Internal") AS ProductName\nFROM Product\n</code></pre>\n\n<p>Gives you what you\'re looking for as well as the previous answers, just adding for completeness.</p>\n'}, {'answer_id': 23872455, 'author': 'Jnn', 'author_id': 2303472, 'author_profile': 'https://Stackoverflow.com/users/2303472', 'pm_score': 2, 'selected': False, 'text': '<pre><code>Select Product.ID, VALUE(product.Name, "Internal") AS ProductName from Product\n</code></pre>\n'}, {'answer_id': 43136634, 'author': 'Md. Kamruzzaman', 'author_id': 4294974, 'author_profile': 'https://Stackoverflow.com/users/4294974', 'pm_score': 3, 'selected': False, 'text': '<p>In DB2 there is a function NVL(field, value if null).</p>\n\n<p>Example:</p>\n\n<p>SELECT ID, NVL(NAME, "Internal) AS NAME, NVL(PRICE,0) AS PRICE FROM PRODUCT WITH UR;</p>\n'}, {'answer_id': 46464702, 'author': 'turnmoil', 'author_id': 7755586, 'author_profile': 'https://Stackoverflow.com/users/7755586', 'pm_score': 0, 'selected': False, 'text': '<p>hope this might help someone else out there</p>\n\n<pre><code>  SELECT \n.... FROM XXX XX\nWHERE\n....\nAND(\n       param1 IS NULL\n       OR XX.param1 = param1\n       )\n</code></pre>\n'}, {'answer_id': 69189273, 'author': 'Rafael Rossi', 'author_id': 7129619, 'author_profile': 'https://Stackoverflow.com/users/7129619', 'pm_score': 0, 'selected': False, 'text': '<p>Another option, in case you need to use if/else, is:</p>\n<pre><code>NVL2 (string_to_be_tested, string_if_not_null, string_if_null);\n</code></pre>\n<p>i.e.:</p>\n<pre><code>SELECT product.ID, NVL2(product.Name, &quot;Internal&quot;, &quot;External&quot;) AS ProductName\nFROM Product;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/65071', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9056/']