Drop a DB2 view if it exists...

Posted by grenade on Stack Overflow See other posts from Stack Overflow or by grenade
Published on 2010-03-22T14:42:36Z Indexed on 2010/03/22 15:31 UTC
Read the original article Hit count: 375

Filed under:
|
|
|

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 http://stackoverflow.com/questions/355687/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.

© Stack Overflow or respective owner

Related posts about sql

Related posts about db2