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

Control Statements in Command Center

P: n/a
Hi

In SQL Server query analyser, I have the follwoing query

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[TabUser4]') and OBJECTPROPERTY(id, N'IsUserTable')
= 1)
drop table [dbo].[TabUser4]
GO

I was wondering if there is an equivalent way of performing such a
query in db2 command centre without having to write a procedure??

thanks
Lyn
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Lyn Duong <ly**@tablimited.com.au> wrote:
Hi

In SQL Server query analyser, I have the follwoing query

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[TabUser4]') and OBJECTPROPERTY(id, N'IsUserTable')
= 1)
drop table [dbo].[TabUser4]
GO

I was wondering if there is an equivalent way of performing such a
query in db2 command centre without having to write a procedure??


(1)
DROP TABLE <schema>.<table>
and then ignore the error code that might have been returned in case the
table did not exist
(2)
SELECT COUNT(*)
FROM syscat.tables
WHERE ( tabschema, tabname ) = ( '<schema>', '<table>' ) AND
type = 'T'

If the return is 1 (one), then run the DROP TABLE.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #2

P: n/a
Hi

Thanks but I was actually looking for something more like a compound
dynamic statement to issue in db2 clp or command center but found that
you can use ddl in these statements anyway. Will need to write a
script with error code checking. Thanks anyway

Lyn

Knut Stolze <st****@de.ibm.com> wrote in message news:<bv**********@fsuj29.rz.uni-jena.de>...
Lyn Duong <ly**@tablimited.com.au> wrote:
Hi

In SQL Server query analyser, I have the follwoing query

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[TabUser4]') and OBJECTPROPERTY(id, N'IsUserTable')
= 1)
drop table [dbo].[TabUser4]
GO

I was wondering if there is an equivalent way of performing such a
query in db2 command centre without having to write a procedure??


(1)
DROP TABLE <schema>.<table>
and then ignore the error code that might have been returned in case the
table did not exist
(2)
SELECT COUNT(*)
FROM syscat.tables
WHERE ( tabschema, tabname ) = ( '<schema>', '<table>' ) AND
type = 'T'

If the return is 1 (one), then run the DROP TABLE.

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.