{"id":274,"date":"2016-07-04T23:01:38","date_gmt":"2016-07-04T22:01:38","guid":{"rendered":"https:\/\/solidt.eu\/blog\/?p=274"},"modified":"2016-07-04T23:01:38","modified_gmt":"2016-07-04T22:01:38","slug":"iseries-retrieve-null-as-column-value","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/iseries-retrieve-null-as-column-value\/","title":{"rendered":"iSeries: Retrieve NULL as column value"},"content":{"rendered":"<p>Original source: <a href=\"http:\/\/techierg.blogspot.nl\/2010\/02\/retrieve-null-in-select-query-in-db2.html\" target=\"_blank\">http:\/\/techierg.blogspot.nl\/2010\/02\/retrieve-null-in-select-query-in-db2.html<\/a><\/p>\n<p>Retrieve NULL in SELECT Query in DB2<\/p>\n<p>Friends, you might have heard about query like this<\/p>\n<p>SELECT NULL FROM [table name]<\/p>\n<p>Now, if you want to do this in DB2, it will return an error that NULL is not a column in the given table name.<\/p>\n<p>To overcome this, you can use two methods<br \/>\nUse NULLIF function like this<\/p>\n<p>Write query like SELECT NULLIF(1, 1) FROM [table name] which will return a NULL value of column type INTEGER because 1 is integer<br \/>\nIf you write  query like SELECT NULLIF(&#8221;, &#8221;) FROM [table name] that will return a NULL value of column type VARCHAR because &#8221; is a string<br \/>\nDon&#8217;t ask me about date. I do not know that with NULLIF function :). Write in comments if you know. I&#8217;ll put it here.<\/p>\n<p>Use CAST function using which you can get NULL value of the column type you want<\/p>\n<p>Write query like SELECT CAST(NULL AS INTEGER) FROM [table name] which will return NULL value of column type INTEGER<br \/>\nIf the query is SELECT CAST(NULL AS VARCHAR(10)) FROM [table name] that will return NULL value of column type VARCHAR<br \/>\nSimilarly SELECT CAST(NULL AS DATE) FROM [table name] that will return NULL value of column type DATE<br \/>\n Hope this helps for some.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Original source: http:\/\/techierg.blogspot.nl\/2010\/02\/retrieve-null-in-select-query-in-db2.html Retrieve NULL in SELECT Query in DB2 Friends, you might have heard about query like this SELECT NULL FROM [table name] Now, if you want to do this in DB2, it will return an error that NULL is not a column in the given table name. To overcome this, you can use [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-274","post","type-post","status-publish","format-standard","hentry","category-other-scripts"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=274"}],"version-history":[{"count":1,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/274\/revisions"}],"predecessor-version":[{"id":275,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/274\/revisions\/275"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}