sql syntax
Posted in 2000
Topics: General Discussion
Hello everybody: I want to check if a table exist in a database,what sql syntax can I write? Now my requirement is follow:(my DB is informix 7.3) If (table exist) then drop table create table ... Thank's everybody. -- Frankie Ke Colovos Machinery Corp TEL:(04)4070810*203 FAX:(04)-4071129 Email:kehunchi@cm1.hinet.net
Use 'select 1 from systables where tabname = youre_table_name' Frankie <kehunchi@cm1.hinet.net> ''''' ' ''''''''':8usth1$2ia7$1@news.is.net.tw... > Hello everybody: > I want to check if a table exist in a database,what sql syntax can I > write? > Now my requirement is follow:(my DB is informix 7.3) > > If (table exist) then > drop table > create table > ... > > > Thank's everybody. > > -- > Frankie Ke > Colovos Machinery Corp > TEL:(04)4070810*203 FAX:(04)-4071129 > Email:kehunchi@cm1.hinet.net > > >
Frankie wrote:
If (table exist) then
> drop table
> create table
This example is from 9.2, but the way that the exception handling is used
comes from 7.X.
When this code returns, the table is guaranteed to be created, regardless
of whether or not it existed at the time that the FUNCTION (read, PROCEDURE)
was invoked.
CREATE PROCEDURE CD ( )
ON EXCEPTION IN (-206)
CREATE TABLE PWD ( etc . . . );
RETURN ;
END EXCEPTION;
DROP TABLE PWD;
DROP TABLE PWD;
RETURN ;
END FUNCTION;