开发者

How to display - Drop table status on Oracle Log file

开发者 https://www.devze.com 2023-03-14 14:55 出处:网络
I have the following on a script file followed by other scripts DECLARE table_exist PLS_INTEGER; BEGIN

I have the following on a script file followed by other scripts

DECLARE table_exist PLS_INTEGER;
 BEGIN
  SELECT COUNT(*) INTO table_exist FROM USER_TABLES WHERE table_name = 'SampleTable';

   IF table_exist = 1 THEN
         EXECUTE IMMEDIATE 'DROP TABLE SampleTable';
   END IF;

END;

.... other script commands .......

I want to know what is the result of the above statement. Currently I have a log file which captures all the script and its result. Since the above statement is not being terminated with a status like Table Dropped the subsequent script command is erroring out. How can this be avoided开发者_如何学编程?


"I added a "/" after the END; and it is now executing correctly."

The slash is necessary to execute a SQL script. So, you add the slash and the script executes, which leads the subsequent scripts to succeed. Who'd a thunk it?

The main point being is, your process is wrong: dynamically dropping tables is a code smell. It may be necessary in certain other RDBMS products but Oracle has lots of functionality. Tell us your actual business requirement and we can tell you a better way to achieve it.

0

精彩评论

暂无评论...
验证码 换一张
取 消