<?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: IF EXISTS..... DROP TABLE in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740355#M3101866</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anton,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did the suggestions help ? Did you find any better option for the requirement ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 May 2012 05:51:11 GMT</pubDate>
    <dc:creator>Ravi_Channe</dc:creator>
    <dc:date>2012-05-16T05:51:11Z</dc:date>
    <item>
      <title>IF EXISTS..... DROP TABLE</title>
      <link>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaq-p/8740347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This might sound like a very stupid question, but I have been going through the HANA PDF's and cannot seem to find the answer I am looking for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am currently in the process of performing a HANA POC and am trying to create a large SQL script that will create multiple tables and populate those tables with some data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Being OCD, I like my scripts to run through with zeros errors. The part where I need the help is in the DROP TABLE part of the script.&lt;/P&gt;&lt;P&gt;I have the DROP TABLE lines there, but if a table does not already exists, I get an error message.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does HANA have the equaivilant of a IF EXISTS ..... DROP TABLE ??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 May 2012 11:47:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaq-p/8740347</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-05-10T11:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: IF EXISTS..... DROP TABLE</title>
      <link>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740348#M3101859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you can make use of TABLES and search for existance of the table (column = table_name) to be dropped.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can write a procedure and also make use of EXISTS (if required).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 May 2012 13:23:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740348#M3101859</guid>
      <dc:creator>Ravi_Channe</dc:creator>
      <dc:date>2012-05-10T13:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: IF EXISTS..... DROP TABLE</title>
      <link>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740349#M3101860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have not use it myself but your SQL should be something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;SPAN style="color: #993333; font-weight: bold;"&gt;IF&lt;/SPAN&gt; &lt;SPAN style="color: #993333; font-weight: bold;"&gt;EXISTS&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt; &lt;SPAN style="color: #66cc66;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #993333; font-weight: bold;"&gt;SELECT&lt;/SPAN&gt; TABLE_NAME &lt;SPAN style="color: #993333; font-weight: bold;"&gt;FROM&lt;/SPAN&gt; SYS_sometabe &lt;SPAN style="color: #993333; font-weight: bold;"&gt;WHERE&lt;/SPAN&gt; field_NAME=&lt;SPAN style="color: #ff0000;"&gt;'&amp;lt;table_name&amp;gt;'&lt;/SPAN&gt;&lt;SPAN style="color: #66cc66;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="color: #993333; font-weight: bold;"&gt;DROP&lt;/SPAN&gt; &lt;SPAN style="color: #993333; font-weight: bold;"&gt;TABLE&lt;/SPAN&gt; &amp;lt;table_name&amp;gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;Rama&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;﻿&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 May 2012 13:41:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740349#M3101860</guid>
      <dc:creator>rama_shankar3</dc:creator>
      <dc:date>2012-05-10T13:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: IF EXISTS..... DROP TABLE</title>
      <link>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740350#M3101861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I jumped too early into this. &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro jive_macro_emoticon jive_emote" src="https://community.sap.com/745/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you mentioned, you need completely ERROR free code which doesn't throw any exception (which I am not sure how to handle in HANA as of now, like specific "No data Found", "SQL Exception" etc).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To achieve this, I think you might have to write a custom program to delete the table with table_name and schema_name as input parameters and dynamic SQL with "EXEC 'DROP TABLE '||&amp;lt;input_table_name&amp;gt;; type command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure if I am over complicating this, but worth a try.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 May 2012 14:16:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740350#M3101861</guid>
      <dc:creator>Ravi_Channe</dc:creator>
      <dc:date>2012-05-10T14:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: IF EXISTS..... DROP TABLE</title>
      <link>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740351#M3101862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As I said, I AM overcomplicating the things.. but what the heck, I could try something new &lt;SPAN __jive_emoticon_name="laugh" __jive_macro_name="emoticon" class="jive_macro jive_macro_emoticon jive_emote" height="1" src="https://community.sap.com/745/images/emoticons/laugh.gif" width="1"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=================================&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop procedure pr_drop_table;&lt;BR /&gt;CREATE PROCEDURE pr_drop_table (&lt;BR /&gt; IN&amp;nbsp; v_in_schema&amp;nbsp;&amp;nbsp;&amp;nbsp; VARCHAR&amp;nbsp; (30), -- Schema Name holding table to be dropped&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IN&amp;nbsp; v_in_table&amp;nbsp;&amp;nbsp; VARCHAR&amp;nbsp; (30)&amp;nbsp;&amp;nbsp;&amp;nbsp; -- Table name to be dropped&lt;BR /&gt;)&lt;BR /&gt;LANGUAGE SQLSCRIPT&lt;BR /&gt;AS&lt;BR /&gt;&amp;nbsp; v_tab_exists smallint := 0;&lt;BR /&gt;BEGIN&lt;/P&gt;&lt;P&gt;-- Create a dummy table&amp;nbsp; &lt;BR /&gt;&amp;nbsp; CREATE TABLE t_dummy (v_tname VARCHAR(30));&lt;/P&gt;&lt;P&gt;-- Insert into the dummy table a value from TABLES with table_name as parameter&lt;/P&gt;&lt;P&gt;&amp;nbsp; INSERT INTO t_dummy&lt;BR /&gt;&amp;nbsp; SELECT table_name FROM TABLES&lt;BR /&gt;&amp;nbsp; WHERE schema_name = :v_in_schema AND table_name = :v_in_table;&lt;/P&gt;&lt;P&gt;-- Check how many records are inserted&lt;BR /&gt;-- If table exists, ROWCOUNT will be 1 or else 0&lt;/P&gt;&lt;P&gt;&amp;nbsp; v_tab_exists := ::ROWCOUNT;&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF v_tab_exists &amp;gt; 0 THEN&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EXEC 'DROP TABLE '||:v_in_table;&lt;BR /&gt;&amp;nbsp; END IF;&lt;/P&gt;&lt;P&gt;-- Delete the dummy table&lt;/P&gt;&lt;P&gt;&amp;nbsp; DROP TABLE t_dummy;&lt;BR /&gt;END;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 May 2012 14:28:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740351#M3101862</guid>
      <dc:creator>Ravi_Channe</dc:creator>
      <dc:date>2012-05-10T14:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: IF EXISTS..... DROP TABLE</title>
      <link>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740352#M3101863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ravi:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; As usual, You Rock Man!&amp;nbsp;&amp;nbsp; Cool..code.... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Thanks for trying it so quickly.&amp;nbsp; I had it in my to-do list to try&amp;nbsp; later tonight...Now its gone...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rama&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 May 2012 14:48:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740352#M3101863</guid>
      <dc:creator>rama_shankar3</dc:creator>
      <dc:date>2012-05-10T14:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: IF EXISTS..... DROP TABLE</title>
      <link>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740353#M3101864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro jive_macro_emoticon jive_emote" height="1" src="https://community.sap.com/745/images/emoticons/happy.gif" width="1"&gt;&lt;/SPAN&gt; .. Thanks..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It was a nice break from my current SQL coding in HANA, where I am trying to re-write a BW transformation ABAP code, in HANA SQL stored procedure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 May 2012 15:03:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740353#M3101864</guid>
      <dc:creator>Ravi_Channe</dc:creator>
      <dc:date>2012-05-10T15:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: IF EXISTS..... DROP TABLE</title>
      <link>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740354#M3101865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for your comments. &lt;/P&gt;&lt;P&gt;I will play around with your suggesstions and report back.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anton&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 05:57:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740354#M3101865</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-05-11T05:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: IF EXISTS..... DROP TABLE</title>
      <link>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740355#M3101866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anton,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did the suggestions help ? Did you find any better option for the requirement ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2012 05:51:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740355#M3101866</guid>
      <dc:creator>Ravi_Channe</dc:creator>
      <dc:date>2012-05-16T05:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: IF EXISTS..... DROP TABLE</title>
      <link>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740356#M3101867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravindra...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems that your process using the proc is teh best solution...&lt;/P&gt;&lt;P&gt;I posted the same question in a couple of places, and you proc solution seems to be/work the best.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for that!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 May 2012 09:19:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740356#M3101867</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-05-17T09:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: IF EXISTS..... DROP TABLE</title>
      <link>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740357#M3101868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a similar question.&lt;/P&gt;&lt;P&gt;I would like to do something like this:&lt;/P&gt;&lt;P&gt;IF EXISTS (SELECT ID FROM&amp;nbsp; &amp;lt;SOME TABLE&amp;gt; WHERE ID=1) THEN&lt;/P&gt;&lt;P&gt; DELETE FROM &amp;lt;SOME TABLE&amp;gt; WHERE ID=1;&lt;/P&gt;&lt;P&gt;END IF;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my &amp;lt;SOME TABLE&amp;gt; only exists in 1 schema but not the other, and I'd like to have the above statement in a stored proc that would be shared by both schema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;however it returns an error saying that &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-size: 10pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Could not execute 'IF EXISTS ... &lt;/P&gt;&lt;SPAN style="color: #ff0000; font-size: 10pt;"&gt;&lt;P&gt;SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near "IF": line 1 col 1 (at pos 1) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 23:28:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740357#M3101868</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-03-04T23:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: IF EXISTS..... DROP TABLE</title>
      <link>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740358#M3101869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This message was moderated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2015 11:28:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740358#M3101869</guid>
      <dc:creator>hamed_dadras</dc:creator>
      <dc:date>2015-04-09T11:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: IF EXISTS..... DROP TABLE</title>
      <link>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740359#M3101870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravindra,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nice function, thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the input should be converted to upper case and I don't know how to fix that in the procedure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Sep 2015 19:05:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-exists-drop-table/qaa-p/8740359#M3101870</guid>
      <dc:creator>pm_witmond</dc:creator>
      <dc:date>2015-09-09T19:05:40Z</dc:date>
    </item>
  </channel>
</rss>

