Why doesn't this work in IBM Data Studio (Eclipse):
IF EXISTS (SELECT 1 FROM SYSIBM.SYSVIEWS WHERE NAME = 'MYVIEW' AND CREATOR = 'MYSCHEMA') THEN
DROP VIEW MYSCHEMA.MYVIEW;
END IF;
I have a feeling it has to do with statement terminators (;) but I can't find a syntax that works.
Another similar question at How to check a procedure/view/table exists or not before dropping it in db2 9.1? suggests that they had to create a proc but this isn't a solution for us.
from IBM's Book: Getting Started with Data Studio for DB2:
EDIT:
OK, the problem seems to be the syntax. Many people seem to have the same problem. Example see DROP TABLE, VIEW, ... only IF EXISTS.
In the example there are two solutions mentioned.
Begin atomic
db2perf_quiet_drop
For details read the liked page.
Second EDIT:
I just found a really good explanation for
Begin ataomic
on the IBM pages. See Advanced SQL Scripting PL from IBM. Example 2 is what you are looking for.