Mother Egg. As a program that uses SQL Server for 4 to 5 years ape, start with Oracle really not used to. It's a hell of a different kind of notation. For example, write a statement like if EXISTS (SELECT * from sys.tables where name = ' xxxx ') BEGIN drop TABLE xxxx End and find that it is completely different under Oracle. Sister's. So Baidu Ah. Finally found
1) Under Oracle There is no if EXISTS (), Oracle to implement if EXISTS () so write
DeclareNum Number; begin Select Count(1) intoNum fromAll_tableswheretable_name= 'TEST2'; ifNum=1 Then ExecuteImmediate'drop table TEST2'; End if; End;
You need to use a variable to store the results of the all_tables output and then judge
2) If ... under SQL Server. BEGIN ... The end to Oracle becomes the IF .... Then ... END IF; and each sentence must be added; It still seems to be necessary.
3) use/to separate two statement blocks to execute
If EXISTS () under Oracle