By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,756 Members | 1,668 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,756 IT Pros & Developers. It's quick & easy.

Hi

P: 4
There are a table in database , i want to check table is exists on not. if it is exists fist it will drop then create the table.
how we can implement it these type of condition in db2. i have write query like that.

IF EXISTS (SELECT * FROM syscat.tables WHERE tabname='AMBCOLUMN')
THEN
Drop table AMBCOLUMN;
ELSE
CREATE TABLE "AMBCOLUMN" ( "COLUMNID" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( START WITH +1 INCREMENT BY +1 MINVALUE +1 MAXVALUE +2147483647 NO CYCLE NO CACHE NO ORDER ) , "TABLEID" INTEGER NOT NULL , "COLNAME" VARCHAR(50) NOT NULL , "DATABASENAME" VARCHAR(255) , "SCHEMANAME" VARCHAR(255) , "TABLENAME" VARCHAR(255) , PRIMARY KEY ( COLUMNID));
END IF;

----------------------------------------------------------------------------------

The give me error like
SQL0104N An unexpected token "IF EXISTS (SELECT *" was found following
"BEGIN-OF-STATEMENT". Expected tokens may include: "<space>".
SQLSTATE=42601

plz help me.............................
Sanjeev.Q3
Oct 31 '07 #1
Share this Question
Share on Google+
2 Replies


P: 4
Hi every one if it is possible give me result ................
Oct 31 '07 #2

P: 9
Please clarify where you are using the statement. Which environment/language are you using?
Nov 2 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.