MySQL Forums
Forum List  »  Triggers

Safely Create Triggers
Posted by: Devang Shah
Date: May 16, 2006 06:05PM

Here is a simple question.

I am careating an application that needs to deploy in automated mode for the development team. That means that I need to clean up prior debris from the database and then install the required database objects in 'batch mode'.

I am experiencing problems with Triggers.

I can DROP PROCEDURE IF EXISTS and DROP TABLE IF EXISTS but there seems no safe way for DROB TRIGGER IF EXISTS.

I even tried the following in my query file (don't mind if the parentheses match, I think you get the idea though )

IF ( NOT ( 0 <= ( SELECT COUNT( * )
FROM INFORMATION_SCHEMA.TRIGGERS
WHERE INFORMATION_SCHEMA.TRIGGERS.TRIGGER_NAME = 'OnUpdateOrganizations'
AND INFORMATION_SCHEMA.TRIGGERS.TRIGGER_SCHEMA = DATABASE() ) ) )
THEN
DROP TRIGGER 'OnUpdateOrganizations';
END IF;

Except, IF/THEN/END IF block is allowed only if it is within a stored procedure. isn't that a hoot.

So, any takers on this otherwise mundane issue ?

Options: ReplyQuote


Subject
Views
Written By
Posted
Safely Create Triggers
2700
May 16, 2006 06:05PM
1803
May 16, 2006 06:43PM
1719
May 16, 2006 06:58PM
1739
May 16, 2006 07:15PM
2025
May 17, 2006 01:13PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.