{"id":55,"date":"2006-10-06T15:01:56","date_gmt":"2006-10-06T14:01:56","guid":{"rendered":"http:\/\/bar-solutions.com\/wordpress\/?p=55"},"modified":"2006-10-06T15:26:10","modified_gmt":"2006-10-06T14:26:10","slug":"qda-reduces-code","status":"publish","type":"post","link":"https:\/\/blog.bar-solutions.com\/?p=55","title":{"rendered":"QDA reduces code&#8230;"},"content":{"rendered":"<p>At my office we are building and supporting software for an insurance company. We have chosen for an architecture where there is one request record. This is connected to one or more variance records, which are in turn connected to the type of insurance. There is also a connection to a number of employees connected to this request. These employees can individually be connected to the insurance record using a result record.<\/p>\n<p>Today I had to create a function that counts the connected result records to a varying record. This should be done for a couple of types, not every type available. We have given the modules, or insurance types, numbers. I had to create this function for modules 14, 15, 16 and 17. For the last three we have the <a title=\"Qnxo Development Architecture\" href=\"http:\/\/www.qnxo.com\/presentations.php\" target=\"_blank\">Qnxo Development Architecture (QDA)<\/a> in place, for module 14 we are not using the QDA yet (due to column name lengths etc.).<\/p>\n<p>To create the function I had to build the code like we did before (before we used the QDA) and use the QDA (where possible). This gave me a good insight in the code that needs to be written with and without the use of the QDA.<\/p>\n<p align=\"left\">FUNCTION pf_aantal_deelnemers(pi_vrn_seqnr IN NUMBER )<br \/>RETURN NUMBER<br \/>IS<br \/>&nbsp; lv_returnvalue NUMBER; <br \/><font color=\"#ff0000\">&nbsp; &#8212; NO QDA available<br \/>&nbsp; &#8212; excedent (14)<br \/>&nbsp; CURSOR c_excedent_14(p_vrn_seqnr NUMBER )<br \/>&nbsp; IS<br \/>&nbsp; SELECT t.ex14_seqnr<br \/>&nbsp;&nbsp;&nbsp; FROM t_excedent_14 t<br \/>&nbsp; &nbsp;WHERE 1 = 1<br \/>&nbsp;&nbsp;&nbsp; &nbsp;AND t.ex14_vrn_seqnr = p_vrn_seqnr; <br \/><\/font><font color=\"#ff0000\">&nbsp; CURSOR c_num_resultaat_14(p_ex14_seqnr NUMBER )<br \/>&nbsp; IS<br \/>&nbsp; SELECT COUNT( * ) the_count<br \/>&nbsp; &nbsp; FROM t_resultaat_14 t<br \/>&nbsp;&nbsp; WHERE 1 = 1<br \/>&nbsp;&nbsp;&nbsp;&nbsp; AND t.rs14_ex14_seqnr = p_ex14_seqnr;&nbsp;<br \/><\/font><font color=\"#ff0000\">&nbsp;&nbsp;rc_excedent_14 c_excedent_14%ROWTYPE;<br \/><\/font><font color=\"#008000\">&#8212; QDA available<br \/>&#8212; WGA-gat (15)<br \/>tc_t_wga_gat_15 t_wga_gat_15_tp.t_wga_gat_15_tc;<br \/>&#8212; WGA ER (16)<br \/>tc_t_wga_er_16 t_wga_er_16_tp.t_wga_er_16_tc;<br \/>&#8212; Vaste aanvulling (17)<br \/>tc_t_wia_aanvulling_17 t_wia_aanvulling_17_tp.t_wia_aanvulling_17_tc;<br \/><\/font>BEGIN<br \/>&nbsp; lv_returnvalue := 0; <br \/><font color=\"#ff0000\">&nbsp; IF c_excedent_14%ISOPEN THEN<br \/>&nbsp;&nbsp;&nbsp; CLOSE c_excedent_14;<br \/>&nbsp; END IF; &#8212; c_excedent_14%IsOpen<br \/>&nbsp; OPEN c_excedent_14( p_vrn_seqnr =&gt; pi_vrn_seqnr );<br \/>&nbsp; FETCH c_excedent_14 INTO rc_excedent_14; <br \/>&nbsp; IF c_excedent_14%FOUND THEN<br \/>&nbsp;&nbsp;&nbsp; IF c_num_resultaat_14%ISOPEN THEN<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CLOSE c_num_resultaat_14;<br \/>&nbsp;&nbsp;&nbsp; END IF; &#8212; c_num_resultaat_14%IsOpen <br \/>&nbsp;&nbsp;&nbsp; OPEN c_num_resultaat_14( p_ex14_seqnr =&gt; rc_excedent_14.ex14_seqnr );<br \/>&nbsp;&nbsp;&nbsp; FETCH c_num_resultaat_14 INTO lv_returnvalue; <br \/>&nbsp;&nbsp;&nbsp; IF c_num_resultaat_14%ISOPEN THEN<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CLOSE c_num_resultaat_14;<br \/>&nbsp;&nbsp;&nbsp; END IF; &#8212; c_num_resultaat_14%IsOpen<br \/>&nbsp;&nbsp;ELSE<br \/>&nbsp;&nbsp;&nbsp; IF c_excedent_14%ISOPEN THEN<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CLOSE c_excedent_14;<br \/>&nbsp;&nbsp;&nbsp; END IF; &#8212; c_excedent_14%IsOpen&nbsp;<br \/><\/font><font color=\"#008000\">&nbsp;&nbsp;&nbsp; tc_t_wga_gat_15 := t_wga_gat_15_qp.ar_fk_wg15_vrn_seqnr<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( wg15_vrn_seqnr_in =&gt; pi_vrn_seqnr ); <br \/>&nbsp;&nbsp;&nbsp; IF tc_t_wga_gat_15.COUNT &gt; 0 THEN<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lv_returnvalue := t_resultaat_15_qp.num_fk_rs15_wg15_seqnr<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( rs15_wg15_seqnr_in =&gt; tc_t_wga_gat_15( 1 ).wg15_seqnr );<br \/>&nbsp;&nbsp;&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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( wa17_vrn_seqnr_in =&gt; pi_vrn_seqnr ); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IF tc_t_wia_aanvulling_17.COUNT &gt; 0 THEN<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lv_returnvalue := t_resultaat_17_qp.num_fk_rs17_wa17_seqnr<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( rs17_wa17_seqnr_in =&gt; tc_t_wia_aanvulling_17( 1 ).wa17_seqnr );<br \/><\/font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ELSE<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lv_returnvalue := 0;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; END IF;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; END IF;<br \/>&nbsp;&nbsp;&nbsp; END IF;<br \/>&nbsp; END IF; <br \/>&nbsp; RETURN lv_returnvalue;<br \/>END pf_aantal_deelnemers; <\/p>\n<p align=\"left\">&nbsp;The code written in <font color=\"#ff0000\">RED<\/font> is &#8216;normal&#8217; PL\/SQL code, the code written in <font color=\"#008000\">GREEN<\/font> is &#8216;QDA&#8217; code.<br \/>As you can see, the code written using the QDA is much less than the &#8216;normal&#8217; code. Each type takes about 4 lines of code , instead of the about 30 lines of code that had to be written to get the job done without the QDA(the <font color=\"#008000\"><strong>GREEN<\/strong><\/font> section is used for <strong>three(!)<\/strong> modules, where the&nbsp;<font color=\"#ff0000\"><strong>RED<\/strong><\/font> section is used for <strong>one(!)<\/strong> module only)&nbsp;.<\/p>\n<p align=\"left\">Of course there is code in the packages of the QDA, but this code is generated by QNXO, so I don&#8217;t have to write this code myself and when I have created these packages once, I can use them in all my custom code.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At my office we are building and supporting software for an insurance company. We have chosen for an architecture where there is one request record. This is connected to one or more variance records, which are in turn connected to the type of insurance. There is also a connection to a number of employees connected [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,8],"tags":[],"class_list":["post-55","post","type-post","status-publish","format-standard","hentry","category-plsql","category-qnxo"],"_links":{"self":[{"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/posts\/55","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=55"}],"version-history":[{"count":0,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/posts\/55\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=55"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=55"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=55"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}