{"id":572,"date":"2012-10-26T06:27:57","date_gmt":"2012-10-26T06:27:57","guid":{"rendered":"http:\/\/bar-solutions.com\/weblog\/?p=572"},"modified":"2012-10-26T06:27:57","modified_gmt":"2012-10-26T05:27:57","slug":"","status":"publish","type":"post","link":"https:\/\/blog.bar-solutions.com\/?p=572","title":{"rendered":"Long time no see"},"content":{"rendered":"<p align=\"left\">It&#8217;s been quite some time since my last post. It&#8217;s not that I haven&#8217;t been busy, just didn&#8217;t find the time or a subject to write a blog about. Until now.<\/p>\n<p align=\"left\">I came up with something I didn&#8217;t know. I have a pipelined table function where I want to suppress a record from appearing when something is wrong (no data found or something like that). I know, suppressing errors is wrong, but in this case I will log the error. I just didn&#8217;t want it to appear in my data because the receiving application will generate errors and reject the entire set of data.<\/p>\n<p><!--more--><\/p>\n<p align=\"left\">The easy way, of course, is not to pipe a row at all, but that would mean adding a lot of complexity to my code so I decided to try something different. Just set the record to NULL before it gets piped out. Adding this worked for my situation but it made me wonder: Is there an empty record added to the &#8216;table&#8217;?<\/p>\n<p>This is why I wrote a simple script to try this:<\/p>\n<div class=\"csharpcode\">\n<pre class=\"alt\"><span class=\"lnum\">   1:  <\/span><span class=\"kwrd\">CREATE OR REPLACE TYPE<\/span> dummy_t <span class=\"kwrd\">AS OBJECT<\/span><\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre><span class=\"lnum\">   2:  <\/span>(<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre class=\"alt\"><span class=\"lnum\">   3:  <\/span>  dummy_id   <span class=\"kwrd\">NUMBER<\/span>,<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre><span class=\"lnum\">   4:  <\/span>  dummy_name <span class=\"kwrd\">VARCHAR2(30)<\/span><\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre class=\"alt\"><span class=\"lnum\">   5:  <\/span>)<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre><span class=\"lnum\">   6:  <\/span>\/<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre class=\"alt\"><span class=\"lnum\">   7:  <\/span><span class=\"kwrd\">CREATE OR REPLACE TYPE<\/span> dummy_ntt <span class=\"kwrd\">AS TABLE OF<\/span> dummy_t<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre><span class=\"lnum\">   8:  <\/span>\/<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre class=\"alt\"><span class=\"lnum\">   9:  <\/span><span class=\"kwrd\">CREATE OR REPLACE FUNCTION<\/span> dummy_f <span class=\"kwrd\">RETURN<\/span> dummy_ntt<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre><span class=\"lnum\">  10:  <\/span>  <span class=\"kwrd\">PIPELINED IS<\/span><\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre class=\"alt\"><span class=\"lnum\">  11:  <\/span>  l_returnvalue dummy_t;<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre><span class=\"lnum\">  12:  <\/span><span class=\"kwrd\">BEGIN<\/span><\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre class=\"alt\"><span class=\"lnum\">  13:  <\/span>  l_returnvalue := dummy_t(1, <span class=\"str\">'Patrick'<\/span>);<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre><span class=\"lnum\">  14:  <\/span>  <span class=\"kwrd\">PIPE ROW<\/span>(l_returnvalue);<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre class=\"alt\"><span class=\"lnum\">  15:  <\/span>  l_returnvalue := <span class=\"kwrd\">NULL<\/span>;<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre><span class=\"lnum\">  16:  <\/span>  <span class=\"kwrd\">PIPE ROW<\/span>(l_returnvalue);<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre class=\"alt\"><span class=\"lnum\">  17:  <\/span>  l_returnvalue := dummy_t(2, <span class=\"str\">'Mitchell'<\/span>);<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre><span class=\"lnum\">  18:  <\/span>  <span class=\"kwrd\">PIPE ROW<\/span>(l_returnvalue);<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre class=\"alt\"><span class=\"lnum\">  19:  <\/span>  <span class=\"kwrd\">RETURN<\/span>;<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre><span class=\"lnum\">  20:  <\/span><span class=\"kwrd\">END<\/span> dummy_f;<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre class=\"alt\"><span class=\"lnum\">  21:  <\/span>\/<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre><span class=\"lnum\">  22:  <\/span><span class=\"kwrd\">SELECT<\/span> *<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre class=\"alt\"><span class=\"lnum\">  23:  <\/span>  <span class=\"kwrd\">FROM<\/span> <span class=\"kwrd\">TABLE<\/span>(dummy_f)<\/pre>\n<\/div>\n<div class=\"csharpcode\">\n<pre><span class=\"lnum\">  24:  <\/span>\/<\/pre>\n<\/div>\n<style type=\"text\/css\">\n<p>.csharpcode, .csharpcode pre\n{\n\tfont-size: small;\n\tcolor: black;\n\tfont-family: consolas, \"Courier New\", courier, monospace;\n\tbackground-color: #ffffff;\n\t\/*white-space: pre;*\/\n}\n.csharpcode pre { margin: 0em; }\n.csharpcode .rem { color: #008000; }\n.csharpcode .kwrd { color: #0000ff; }\n.csharpcode .str { color: #006080; }\n.csharpcode .op { color: #0000c0; }\n.csharpcode .preproc { color: #cc6633; }\n.csharpcode .asp { background-color: #ffff00; }\n.csharpcode .html { color: #800000; }\n.csharpcode .attr { color: #ff0000; }\n.csharpcode .alt \n{\n\tbackground-color: #f4f4f4;\n\twidth: 100%;\n\tmargin: 0em;\n}\n.csharpcode .lnum { color: #606060; }<\/style>\n<p align=\"left\">As you can see, there are three PIPE ROW statements so you might expect three rows in the result. But luckily <a title=\"Oracle\" href=\"http:\/\/www.oracle.com\/\" rel=\"nofollow\" target=\"_blank\">Oracle<\/a> is smart enough to suppress the empty row:<\/p>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\" width=\"346\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"94\">DUMMY_ID<\/td>\n<td valign=\"top\" width=\"250\">DUMMY_NAME<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"94\">&#8212;&#8212;&#8212;-<\/td>\n<td valign=\"top\" width=\"250\">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"94\">1<\/td>\n<td valign=\"top\" width=\"250\">Patrick<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"94\">2<\/td>\n<td valign=\"top\" width=\"250\">Mitchell<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"csharpcode\">\n<pre><\/pre>\n<\/div>\n<style type=\"text\/css\">.csharpcode, .csharpcode pre\n{\n\tfont-size: small;\n\tcolor: black;\n\tfont-family: consolas, \"Courier New\", courier, monospace;\n\tbackground-color: #ffffff;\n\t\/*white-space: pre;*\/\n}\n.csharpcode pre { margin: 0em; }\n.csharpcode .rem { color: #008000; }\n.csharpcode .kwrd { color: #0000ff; }\n.csharpcode .str { color: #006080; }\n.csharpcode .op { color: #0000c0; }\n.csharpcode .preproc { color: #cc6633; }\n.csharpcode .asp { background-color: #ffff00; }\n.csharpcode .html { color: #800000; }\n.csharpcode .attr { color: #ff0000; }\n.csharpcode .alt \n{\n\tbackground-color: #f4f4f4;\n\twidth: 100%;\n\tmargin: 0em;\n}\n.csharpcode .lnum { color: #606060; }\n<\/style>\n<p align=\"left\">This is what I hoped would happen and luckily it did so.<\/p>\n<p align=\"left\">What else have I been up to?<br \/>I am currently in the process of rating abstracts for <a title=\"KScope13\" href=\"http:\/\/www.kscope13.com\" rel=\"nofollow\" target=\"_blank\">KScope13<\/a> being a Track Lead for the <small>Developer&#8217;s Toolkit. <br \/>I have published a couple of articles on the <a title=\"All Things Oracle - Content for Oracle Developers and DBAs\" href=\"http:\/\/allthingsoracle.com\/\" rel=\"nofollow\" target=\"_blank\">AllThingsOracle<\/a> website with the latest addition being an article on Edition Based Redefinition (<a title=\"Edition Based Redefinition &ndash; Part 1 &ndash; All Things Oracle\" href=\"http:\/\/allthingsoracle.com\/edition-based-redefinition-part-1\/\" rel=\"nofollow\" target=\"_blank\">part 1<\/a>, part 2 hopefully next week). Other articles I wrote here can be found at <a title=\"Patrick Barel &ndash; All Things Oracle\" href=\"http:\/\/allthingsoracle.com\/author\/patrick-barel\/\" rel=\"nofollow\" target=\"_blank\">this link<\/a>.<br \/>Besides that<\/small> I&#8217;m still playing around with <a title=\"Oracle Application Express\" href=\"https:\/\/apex.oracle.com\/\" rel=\"nofollow\" target=\"_blank\">APEX<\/a> trying to rebuild a program I wrote a long time ago in <a title=\"PHP: Hypertext Preprocessor\" href=\"http:\/\/www.php.net\/\" rel=\"nofollow\" target=\"_blank\">PHP<\/a> using <a title=\"MySQL: The world's most popular open source database\" href=\"http:\/\/dev.mysql.com\/\" rel=\"nofollow\" target=\"_blank\">MySQL<\/a> to build my own version of <a title=\"Delicious\" href=\"http:\/\/delicious.com\/home\" rel=\"nofollow\" target=\"_blank\">Delicious<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s been quite some time since my last post. It&#8217;s not that I haven&#8217;t been busy, just didn&#8217;t find the time or a subject to write a blog about. Until now. I came up with something I didn&#8217;t know. I have a pipelined table function where I want to suppress a record from appearing when [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,2,5,9],"tags":[],"class_list":["post-572","post","type-post","status-publish","format-standard","hentry","category-apex","category-oracle","category-plsql","category-sql"],"_links":{"self":[{"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/posts\/572","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=572"}],"version-history":[{"count":0,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/posts\/572\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=572"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}