Results 1 to 5 of 5

Thread: SQL help

  1. #1
    Join Date
    Apr 2004
    Location
    Inside Intel
    Posts
    165

    Talking Unanswered: 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

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  3. #3
    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

  4. #4
    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

  5. #5
    Join Date
    Apr 2004
    Location
    Inside Intel
    Posts
    165

    Talking

    Hmm.... Any takers?

    Thanks in Advance,
    Newbie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •