<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: drop table in execute immediate in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaa-p/13850268#M4881111</link>
    <description>&lt;P&gt;Sorry for the inconvinience, the problem was that one of the triggers was including ',' in its name (in trigname).&lt;/P&gt;
&lt;P&gt;Problem was solved after adding "" to the table name:&lt;/P&gt;
&lt;P&gt;execute immediate ('drop trigger "' + tname + '"')&lt;/P&gt;</description>
    <pubDate>Fri, 08 Mar 2019 08:38:13 GMT</pubDate>
    <dc:creator>Baron</dc:creator>
    <dc:date>2019-03-08T08:38:13Z</dc:date>
    <item>
      <title>drop table in execute immediate</title>
      <link>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaq-p/13850261</link>
      <description>&lt;P&gt;I am trying to build a cursor on systable to find all old tables, and then exceute drop table statement on all those tables:&lt;/P&gt;
&lt;P&gt;declare tnames insensitive cursor for select table_name from systable where table_name like '%_old';&lt;/P&gt;
&lt;P&gt;and then within the loop I execute the drop statement:&lt;/P&gt;
&lt;P&gt;execute immediate ('drop table ' + tname) ;&lt;/P&gt;
&lt;P&gt;I rceive an error stating that the cursor is not open!! Is this generally possible? Is there any other alternative?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 07:21:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaq-p/13850261</guid>
      <dc:creator>Baron</dc:creator>
      <dc:date>2019-03-07T07:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: drop table in execute immediate</title>
      <link>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaa-p/13850262#M4881105</link>
      <description>&lt;P&gt;See that &lt;A href="https://sqlanywhere-forum.sap.com/questions/510/why-does-my-cursor-fetch-loop-stop-after-one-pass"&gt;old question&lt;/A&gt; on cursor loops and statements within the loop that do an automatic commit (like DROP TABLE does).&lt;/P&gt;
&lt;P&gt;Basically, you have to make sure the cursor is hold open, for details see Bruce's answer.&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;To add: You could also adapt the "close_on_endtrans" option but I would not recommend that.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 07:39:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaa-p/13850262#M4881105</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2019-03-07T07:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: drop table in execute immediate</title>
      <link>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaa-p/13850263#M4881106</link>
      <description>&lt;P&gt;DROP TABLE has an implicit commit which closes the cursor . You will need to OPEN the cursor WITH HOLD .&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 07:41:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaa-p/13850263#M4881106</guid>
      <dc:creator>chris_keating</dc:creator>
      <dc:date>2019-03-07T07:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: drop table in execute immediate</title>
      <link>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaa-p/13850264#M4881107</link>
      <description>&lt;P&gt;&amp;gt; the "close_on_endtrans" option but I would not recommend that.&lt;/P&gt;
&lt;P&gt;Why not? The FOR loop works just like close_on_endtrans = off, and FOR is often an excellent alternative to DECLARE OPEN FETCH.&lt;/P&gt;
&lt;P&gt;In fact, I cannot recall a single time when implicitly closing a cursor on COMMIT or ROLLBACK was the desired behavior.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 08:53:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaa-p/13850264#M4881107</guid>
      <dc:creator>Breck_Carter</dc:creator>
      <dc:date>2019-03-07T08:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: drop table in execute immediate</title>
      <link>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaa-p/13850265#M4881108</link>
      <description>&lt;P&gt;Well, because the option will affect all transactions (unless set temporarily or only connection-wise) and all cursors, and I guess most cursors are used "behind the curtain" in database applications, and I would be hesitant to possibly modify their behaviour.&lt;/P&gt;
&lt;P&gt;Therefore, I strongly suggest to use a local cursor WITH HOLD or - even better - the great FOR loop. (I almost always use cursor loops with FOR, I only do not use them when the implicit WITH HOLD is not desired:...)&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 09:12:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaa-p/13850265#M4881108</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2019-03-07T09:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: drop table in execute immediate</title>
      <link>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaa-p/13850266#M4881109</link>
      <description>&lt;P&gt;One more question, does the same work for dropping triggers?&lt;/P&gt;
&lt;P&gt;declare tnames insensitive cursor for select trigname from systriggers;&lt;/P&gt;
&lt;P&gt;execute immediate ('drop trigger ' + tname) ;&lt;/P&gt;
&lt;P&gt;I receive a syntax error!!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 04:25:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaa-p/13850266#M4881109</guid>
      <dc:creator>Baron</dc:creator>
      <dc:date>2019-03-08T04:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: drop table in execute immediate</title>
      <link>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaa-p/13850267#M4881110</link>
      <description>&lt;P&gt;Do you supply the trigger name or the table name to the DROP TRIGGER statement? The trigger name is mandatory.&lt;/P&gt;
&lt;P&gt;Are the trigger names unique? Otherwise, you need to specify the table (and possibly owner) name, too.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 06:13:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaa-p/13850267#M4881110</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2019-03-08T06:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: drop table in execute immediate</title>
      <link>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaa-p/13850268#M4881111</link>
      <description>&lt;P&gt;Sorry for the inconvinience, the problem was that one of the triggers was including ',' in its name (in trigname).&lt;/P&gt;
&lt;P&gt;Problem was solved after adding "" to the table name:&lt;/P&gt;
&lt;P&gt;execute immediate ('drop trigger "' + tname + '"')&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 08:38:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/drop-table-in-execute-immediate/qaa-p/13850268#M4881111</guid>
      <dc:creator>Baron</dc:creator>
      <dc:date>2019-03-08T08:38:13Z</dc:date>
    </item>
  </channel>
</rss>

