Submit your use case or success story to the 2023 edition of the Dataiku Frontrunner Awards ENTER YOUR SUBMISSION

writing sql queries to modify oracle DB

soprano
Level 1
writing sql queries to modify oracle DB

Hello everyone,

I am trying to write an sql query that drops a table from an oracle DB if it exists , otherwise it doesn't generate any errors.

I tried with this code : 

DECLARE

nb number;

BEGIN 

SELECT count *

into nb

FROM tables

WHERE table_name = 'my_table';

IF nb = 1 THEN

EXECUTE IMMEDIATE  'DROP TABLE my_table';

END IF;

END;

--DKU_END_STATEMENT

But it does not work. Can anyone help me please with the right syntax that conveys the goal !

Thank you so very much in advance.

 

0 Kudos
0 Replies