{"id":158,"date":"2007-07-08T17:46:37","date_gmt":"2007-07-08T16:46:37","guid":{"rendered":"http:\/\/bar-solutions.com\/wordpress\/?p=158"},"modified":"2007-07-08T17:46:39","modified_gmt":"2007-07-08T16:46:39","slug":"by-position-or-by-name","status":"publish","type":"post","link":"https:\/\/blog.bar-solutions.com\/?p=158","title":{"rendered":"By position or by name&#8230;"},"content":{"rendered":"<p>In Oracle PL\/SQL you have the possibility to call another program with parameters either by position or by name. Both have their pros and cons I think.<\/p>\n<p>Consider the betwnstr function (<a title=\"Automatic Syntax Highlighting\" href=\"http:\/\/bar-solutions.com\/wordpress\/?p=157\" target=\"_blank\">posted last time<\/a>) and these calls (all have the same result):<\/p>\n<\/p>\n<div class=\"wlWriterSmartContent\" id=\"57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:a31eb5bb-6c66-444d-a0bf-db0c1961ba05\" contenteditable=\"false\" style=\"padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px\">\n<pre style=\"background-color:White;;overflow: auto;\"><div><!--\n\nCode highlighting produced by Actipro CodeHighlighter (freeware)\nhttp:\/\/www.CodeHighlighter.com\/\n\n--><span style=\"color: #000000; \">l_varchar :<\/span><span style=\"color: #000000; \">=<\/span><span style=\"color: #000000; \"> betwnstr(<\/span><span style=\"color: #800000; \">'<\/span><span style=\"color: #800000; \">hello world<\/span><span style=\"color: #800000; \">'<\/span><span style=\"color: #000000; \">\n                     , <\/span><span style=\"color: #800080; \">3<\/span><span style=\"color: #000000; \">\n                     , <\/span><span style=\"color: #800080; \">5<\/span><span style=\"color: #000000; \">\n                     , <\/span><span style=\"color: #0000FF; \">true<\/span><span style=\"color: #000000; \">);\n\nl_varchar :<\/span><span style=\"color: #000000; \">=<\/span><span style=\"color: #000000; \"> betwnstr(<\/span><span style=\"color: #800000; \">'<\/span><span style=\"color: #800000; \">hello world<\/span><span style=\"color: #800000; \">'<\/span><span style=\"color: #000000; \">\n                     , <\/span><span style=\"color: #800080; \">3<\/span><span style=\"color: #000000; \">\n                     , <\/span><span style=\"color: #800080; \">5<\/span><span style=\"color: #000000; \">);\n\nl_varchar :<\/span><span style=\"color: #000000; \">=<\/span><span style=\"color: #000000; \"> betwnstr( string_in <\/span><span style=\"color: #000000; \">=&gt;<\/span><span style=\"color: #000000; \"> <\/span><span style=\"color: #800000; \">'<\/span><span style=\"color: #800000; \">hello world<\/span><span style=\"color: #800000; \">'<\/span><span style=\"color: #000000; \">\n                     , start_in <\/span><span style=\"color: #000000; \">=&gt;<\/span><span style=\"color: #000000; \"> <\/span><span style=\"color: #800080; \">3<\/span><span style=\"color: #000000; \">\n                     , end_in <\/span><span style=\"color: #000000; \">=&gt;<\/span><span style=\"color: #000000; \"> <\/span><span style=\"color: #800080; \">5<\/span><span style=\"color: #000000; \">\n                     , inclusive_in <\/span><span style=\"color: #000000; \">=&gt;<\/span><span style=\"color: #000000; \"> <\/span><span style=\"color: #0000FF; \">true<\/span><span style=\"color: #000000; \">);\n\nl_varchar :<\/span><span style=\"color: #000000; \">=<\/span><span style=\"color: #000000; \"> betwnstr( string_in <\/span><span style=\"color: #000000; \">=&gt;<\/span><span style=\"color: #000000; \"> <\/span><span style=\"color: #800000; \">'<\/span><span style=\"color: #800000; \">hello world<\/span><span style=\"color: #800000; \">'<\/span><span style=\"color: #000000; \">\n                     , start_in <\/span><span style=\"color: #000000; \">=&gt;<\/span><span style=\"color: #000000; \"> <\/span><span style=\"color: #800080; \">3<\/span><span style=\"color: #000000; \">\n                     , end_in <\/span><span style=\"color: #000000; \">=&gt;<\/span><span style=\"color: #000000; \"> <\/span><span style=\"color: #800080; \">5<\/span><span style=\"color: #000000; \">);<\/span><\/div><\/pre>\n<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http:\/\/dunnhq.com --><\/div>\n<\/p>\n<p>Which one of these calls is better? Oracle doesn&#8217;t mind. To the PL\/SQL engine they are all valid and all correct. I don&#8217;t even think there is a performance issue with either one of them.<\/p>\n<p><!--more--><\/p>\n<p>What are my thoughts on this issue:<br \/>&#8211; Calling programs with parameters by name is better because you can skip the defaulted parameters which are in between other (non defaulted) parameters.<br \/>&#8211; Calling programs with parameters by name is better because it&#8217;s more self documenting, you describe what variable goes into what parameter.<br \/>&#8211; If you rearrange the parameters, for whatever reason, your programs calling this one will still be working.<\/p>\n<p>Calling programs with parameters by position is better because&#8230; well, not many pros I can think of for this approach. It&#8217;s mostly &#8216;old&#8217; code I come across that calls programs with parameters by position. I always have to check the called program to see what the parameters mean.<\/p>\n<p>Which one (in your opinion) is better.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Oracle PL\/SQL you have the possibility to call another program with parameters either by position or by name. Both have their pros and cons I think. Consider the betwnstr function (posted last time) and these calls (all have the same result): l_varchar := betwnstr(&#8216;hello world&#8217; , 3 , 5 , true); l_varchar := betwnstr(&#8216;hello [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,5],"tags":[],"class_list":["post-158","post","type-post","status-publish","format-standard","hentry","category-oracle","category-plsql"],"_links":{"self":[{"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/posts\/158","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=158"}],"version-history":[{"count":0,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/posts\/158\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}