Hi, new to DB2, how do I issue a drop index only if it exists? I thought I had worked it out (pretty similar to SQL Server, which I know well), but it fails. I have seen a number of questions about this but as yet no satisfactory answer. This is what I tried and the result - can anyone help?
Thanks
Product info -
Microsoft Windows XP [Version 5.1.2600]
DB21085I Instance "DB2" uses "32" bits and DB2 code release "SQL08024" with level identifier "03050106".
Informational tokens are "DB2 v8.1.11.973", "s060120", "WR21365", and FixPak "11".
Product Name = "DB2 Personal Edition"
Product Identifier = "DB2PE"
Version Information = "8.2"
------------------------------ Commands Entered -------------------------
IF EXISTS (SELECT name FROM sysibm.sysindexes WHERE name = 'IX_D_EXP_01')
THEN
DROP INDEX IX_D_EXP_01;
END IF
--------------------------------------------------------------------------
IF EXISTS (SELECT name FROM sysibm.sysindexes WHERE name = 'IX_D_EXP_01') THEN DROP INDEX IX_D_EXP_01
DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "IF EXISTS (SELECT name FROM sysibm.sysindex"
was found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<space>". SQLSTATE=42601
END IF
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "END-OF-STATEMENT" was found following "END IF".
Expected tokens may include: "JOIN <joined_table>". SQLSTATE=42601
SQL0104N An unexpected token "END-OF-STATEMENT" was found following "END IF". Expected tokens may include: "JOIN <joined_table>