{"id":464,"date":"2010-03-28T15:17:20","date_gmt":"2010-03-28T14:17:20","guid":{"rendered":"http:\/\/bar-solutions.com\/weblog\/?p=464"},"modified":"2010-03-28T15:17:20","modified_gmt":"2010-03-28T14:17:20","slug":"codegen-and-apex","status":"publish","type":"post","link":"https:\/\/blog.bar-solutions.com\/?p=464","title":{"rendered":"CodeGen and APEX."},"content":{"rendered":"<p>When building code to support your APEX application, it is always nice to be able to generate large parts of that code. I am really fond of creating code using the QDA. The only trouble is that you need to create all the packages separately. What I have found works for me is to create a single script for the sequence, all the packages and the trigger creation. This is something that had to be done by hand because QNXO generates separate files for the different parts of the Table API.<!--more--><br \/>\nI could create a new script and just copy in all the lines in the other scripts, but what would happen if one was to change? I would have to make that change in multiple places. Something I would rather not do. So instead of creating a new script with copies of the current code I decided to copy the &#8216;install&#8217; script and adapt that to create the complete install script. Instead of calling a different file using the @@ option in SQL*Plus (or PL\/SQL Developer of course), I [INCLUDE]d the scripts I needed. This way I am using the exact same script which is being used when creating the QDA scripts &#8216;the old way&#8217;. I had a bit of a problem generating the sequence and the triggers. I appeared that some setup scripts were not run.<br \/>\nIn the existing &#8216;tree&#8217; these scripts were run at different levels of the hierarchy. I could of course create a similar hierarchy, but I don&#8217;t want that. I don&#8217;t like to be constrained to a special way to work. CodeGen supplies the possibility to run setup scripts prior to the actual script. There is my way out. I want to run some setup scripts prior to my actual script.<br \/>\nThe setup scripts that need to be executed:<br \/>\n<strong>NAMING-CONVENTIONS-FOR:&#8221;QCGU Development Architecture for PL\/SQL&#8221;<\/strong><br \/>\n<strong>QDA_flags_for_table_processing<\/strong><br \/>\nThe actual script:<br \/>\n<code>REM One full install script for the QDA code<br \/>\nREM Based on the existing scripts.<br \/>\nREM SPOD: Single Point Of Definition<br \/>\nREM (c) 2010: Bar Solutions<br \/>\n[include]primary_key_generation_controls<br \/>\n#<br \/>\n# Remove any lines that aren't relevant.<br \/>\n#<br \/>\nREM Remove any lines you don't need or don't apply to your situtation.<\/p>\n<p># 1.4 Do not always include this line.<br \/>\n[IF]{qda_generating_pky}[EQ]{qda_true}[AND]{pkycoldatatype_sql}[IN]INTEGER,NUMBER<br \/>\nCREATE SEQUENCE {sequence_name:[objname\/a]};<\/p>\n<p>[ENDIF]<br \/>\n[INCLUDE]Types Package Specification<br \/>\nSHOW ERRORS<br \/>\n[INCLUDE]Query Package Specification<br \/>\nSHOW ERRORS<br \/>\n[INCLUDE]Change Package Specification<br \/>\nSHOW ERRORS<br \/>\n[IF]{include_utility_packages}[EQ]{qda_true}<br \/>\n[INCLUDE]Utilities package specification<br \/>\nSHOW ERRORS<br \/>\n[ENDIF]<br \/>\n[INCLUDE]Query Package Body<br \/>\nSHOW ERRORS<br \/>\n[INCLUDE]Change Package Body<br \/>\nSHOW ERRORS<br \/>\n[IF]{include_utility_packages}[EQ]{qda_true}<br \/>\n[INCLUDE]Utilities package body<br \/>\nSHOW ERRORS<br \/>\n[ENDIF]<br \/>\n#<br \/>\n# 1.4 Apply logic here from the audit trigger script<br \/>\n[SETALIAS]l_pky_gen[TO]{qda_false}<br \/>\n[IF]{qda_generating_pky}[EQ]{qda_true}[AND]onepkycol<br \/>\n  [SETALIAS]l_pky_gen[TO]{qda_true}<br \/>\n[ENDIF]<br \/>\n[IF]{l_pky_gen}[EQ]{qda_true}[OR][-]<br \/>\n    {grp_int_table}[EQ]{qda_true}[OR][-]<br \/>\n    {have_audit_columns}[EQ]{qda_true}<br \/>\n[INCLUDE]Audit triggers<br \/>\n[ENDIF]<\/code><br \/>\nAnd of course I need to copy the arguments from the scripts that are executed when I run the entire script group.<br \/>\nAnd there it is, a single script to install the packages for the QDA.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When building code to support your APEX application, it is always nice to be able to generate large parts of that code. I am really fond of creating code using the QDA. The only trouble is that you need to create all the packages separately. What I have found works for me is to create [&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,12,2],"tags":[],"class_list":["post-464","post","type-post","status-publish","format-standard","hentry","category-apex","category-codegen","category-oracle"],"_links":{"self":[{"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/posts\/464","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=464"}],"version-history":[{"count":6,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/posts\/464\/revisions"}],"predecessor-version":[{"id":471,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/posts\/464\/revisions\/471"}],"wp:attachment":[{"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}