If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > SQL help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-20-04, 11:52
dsusendran dsusendran is offline
Registered User
 
Join Date: Apr 2004
Location: Inside Intel
Posts: 165
Talking SQL help

Hi all,

How do i do something like:

IF <STORED_PROCEDURE> EXISTS THEN
DROP <STORED_PROCEDURE>
ELSE <CONTINUE_DOING_SOMETHING>

Thanks in advance,

Newbie

DB2 8.1.6 on Windows 2000
Reply With Quote
  #2 (permalink)  
Old 07-20-04, 13:21
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
You should be able to find the stored procedure name listed in one of the DB2 system catalog tables. The SYSCAT views are documented in the appendix of Vol 1 of the SQL Reference manual.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 07-20-04, 13:39
dsusendran dsusendran is offline
Registered User
 
Join Date: Apr 2004
Location: Inside Intel
Posts: 165
Smile

Hi,

Thanks for the prompt reply. I know SYSCAT.PROCEDURES has the procedure name in PROCNAME column. I want to do a conditional check before i drop/create procedure. I am trying to write a SQL script to deploy TABLES/PROCEDURES/FUNCTIONS on another server.

Newbie
Reply With Quote
  #4 (permalink)  
Old 07-20-04, 15:03
dsusendran dsusendran is offline
Registered User
 
Join Date: Apr 2004
Location: Inside Intel
Posts: 165
Talking

Something like this in MS-SQL:

IF EXISTS (SELECT * FROM sysobjects WHERE name = 'TEST')

DROP TABLE dbo.TEST;

Thanks,
Newbie
Reply With Quote
  #5 (permalink)  
Old 07-21-04, 09:58
dsusendran dsusendran is offline
Registered User
 
Join Date: Apr 2004
Location: Inside Intel
Posts: 165
Talking

Hmm.... Any takers?

Thanks in Advance,
Newbie
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On