siddharth
01-14-02, 03:50
| Hi, How can we write a SQL statement to drop a table. The drop statement should not generate any error if the table doesn't exists. I have achieved the same in Oracle by catching the 'table not found exception' The code I wrote is as follows: CREATE PROCEDURE drop_table(pTableName VARCHAR2) IS vCommand VARCHAR2(1024); table_not_exist EXCEPTION; PRAGMA EXCEPTION_INIT(table_not_exist,-942); BEGIN vCommand := 'DROP TABLE ' || pTableName || ' CASCADE CONSTRAINTS'; EXECUTE IMMEDIATE vCommand; EXCEPTION WHEN table_not_exist THEN NULL; WHEN OTHERS THEN RAISE; END drop_table; Can I do something equivalent in Sybase? Thanks, Siddharth |