{"id":57,"date":"2006-11-06T15:07:02","date_gmt":"2006-11-06T14:07:02","guid":{"rendered":"http:\/\/bar-solutions.com\/wordpress\/?p=57"},"modified":"2006-11-06T15:07:03","modified_gmt":"2006-11-06T14:07:03","slug":"cleanup-after-yourself","status":"publish","type":"post","link":"https:\/\/blog.bar-solutions.com\/?p=57","title":{"rendered":"Cleanup after yourself"},"content":{"rendered":"<\/p>\n<p>When working with your own arrays in Qnxo, you end up with all kinds of views in the schema that you actually don&#8217;t want to be left there. For one because they don&#8217;t serve any purpose, except for the CGML code generation, and you don&#8217;t want any other code to depend on them, because they might change during another generation run.&nbsp; <\/p>\n<p>CGML doesn&#8217;t provide a utility to clean up these views, but you can call PL\/SQL code in the database to have the job done for you.  <\/p>\n<p>I have created a package like this:  <\/p>\n<blockquote>\n<p>CREATE OR REPLACE PACKAGE cgml_tools AUTHID CURRENT_USER <br \/>IS <br \/>&nbsp; v_string&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;VARCHAR2( 32767 ); <br \/>&nbsp; FUNCTION drop_view <br \/>&nbsp; &nbsp; RETURN NUMBER; <br \/>END cgml_tools; <br \/>\/ <br \/>CREATE OR REPLACE PACKAGE BODY cgml_tools <br \/>IS <br \/>&nbsp; FUNCTION drop_view <br \/>&nbsp; &nbsp; RETURN NUMBER <br \/>&nbsp; IS <br \/>&nbsp; BEGIN <br \/>&nbsp; &nbsp; EXECUTE IMMEDIATE &#8216;drop view &#8216; || v_string; <br \/>&nbsp; &nbsp; RETURN 0; <br \/>&nbsp; END drop_view; <br \/>BEGIN <br \/>&nbsp; &#8212; Initialization <br \/>&nbsp; NULL; <br \/>END cgml_tools; <\/p>\n<\/blockquote>\n<p>Now, when I create an <b>array<\/b> like this:  <\/p>\n<blockquote>\n<p>[DEFARRAY]my_array[AS] <br \/>SELECT &#8216;Hello world&#8217; <br \/>&nbsp; FROM DUAL <br \/>[ENDDEFARRAY] <\/p>\n<\/blockquote>\n<p>then a view called my_array is created in the current schema. <br \/>When I issue this code at the end of my script:<\/p>\n<blockquote>\n<p># clean up after yourself!!! <br \/>[SET]cgml_tools.v_string[TO]MY_ARRAY <br \/>[SETALIAS]_dummy[TO]{cgml_tools.drop_view} <\/p>\n<\/blockquote>\n<p>Then the view is removed after it has served it&#8217;s purpose. <\/p>\n<p>Maybe you are wondering why I created a package and not just a function with a single parameter. The reason for this is that CGML can call PL\/SQL Code, but cannot send in parameters (for as far as I know, at least). Using a package gives me the opportunity to use a package variable as a parameter.<\/p>\n<p>Hope this helps other people too.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When working with your own arrays in Qnxo, you end up with all kinds of views in the schema that you actually don&#8217;t want to be left there. For one because they don&#8217;t serve any purpose, except for the CGML code generation, and you don&#8217;t want any other code to depend on them, because they [&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,8],"tags":[],"class_list":["post-57","post","type-post","status-publish","format-standard","hentry","category-oracle","category-plsql","category-qnxo"],"_links":{"self":[{"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/posts\/57","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=57"}],"version-history":[{"count":0,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/posts\/57\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=57"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=57"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}