 {"id":158,"date":"2020-03-24T11:36:32","date_gmt":"2020-03-24T10:36:32","guid":{"rendered":"http:\/\/www.pastscho.de\/?p=158"},"modified":"2020-03-24T11:50:46","modified_gmt":"2020-03-24T10:50:46","slug":"sql-generate-and-excecute","status":"publish","type":"post","link":"https:\/\/www.pastscho.de\/?p=158","title":{"rendered":"SQL generate and excecute"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Mit dem folgenden Statement (Anonymer Block) kann DDL erstellt und ausgef\u00fchrt werden.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>set serveroutput on;\nset serveroutput on size unlimited;\n--------------------------------------------------------------------------------\n-- 24.03.2020 SHESS Dieser Block entfernt Views innerhalb eines Schemas.\n--                  Die zu l\u00f6schende Views werden durch die \n--                  WHERE-CLAUSE eingeschr\u00e4nkt.\n-- \n--\n--\n\nDECLARE\n   ddl2excecute VARCHAR2(8096) ;\n   i NUMBER := 1;\nBEGIN\n--\n  FOR txt IN (  SELECT 'DROP VIEW '||view_name ddl2excecute ,view_name\n                  FROM user_views \n                 WHERE SUBSTR(view_name,1,3)= 'VIEW_PREFIX'\n              ORDER BY view_name\n             )\n  LOOP\n   \n     ddl2excecute := txt.ddl2excecute;\n     EXECUTE IMMEDIATE  ddl2excecute;\n     DBMS_OUTPUT.PUT_LINE(' View entfernt: ' ||LPAD(TO_CHAR (i),3,'0')|| ' ' || txt.view_name);\n     i := i +1;\n\n  END LOOP;\nEXCEPTION\n  WHEN OTHERS THEN RAISE;\n  DBMS_OUTPUT.PUT_LINE(' Ora  ' ||SQLERRM);\n--\nEND;\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Mit dem folgenden Statement (Anonymer Block) kann DDL erstellt und ausgef\u00fchrt werden.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,10,16],"tags":[],"class_list":["post-158","post","type-post","status-publish","format-standard","hentry","category-etl","category-oracle-database","category-sql"],"_links":{"self":[{"href":"https:\/\/www.pastscho.de\/index.php?rest_route=\/wp\/v2\/posts\/158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pastscho.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pastscho.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pastscho.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pastscho.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=158"}],"version-history":[{"count":4,"href":"https:\/\/www.pastscho.de\/index.php?rest_route=\/wp\/v2\/posts\/158\/revisions"}],"predecessor-version":[{"id":160,"href":"https:\/\/www.pastscho.de\/index.php?rest_route=\/wp\/v2\/posts\/158\/revisions\/160"}],"wp:attachment":[{"href":"https:\/\/www.pastscho.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pastscho.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pastscho.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}