Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

does any one know how i can delete a trigger if it exist in mysql ?

 
raminaa niilian
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
thank you for reading my post
i am trying to make it possible to use an script file to inject all triggers that i need into database.
but problem is that if a trigger is already there i can not check for its existance .

when i can not check for its existence then i do not know whether i should have a drop trigger statement or not.

Mysql does not support Drop if exisits for triggers.
i want a clone for drop if exisits TRIGGER_NAME
or Create or replace triger commands.

Thank you very much.

any comment ?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34671
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raminaa,
See this page where someone suggested doing a count first.
 
raminaa niilian
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for you reply.
I saw that post before , my problem is that i do not know how i can use that sql statement , i know that it return the count of rows with the same trigger name , then i do not know how i can use that count in sql statement.

if it was using java simpley i check the first column of first row then i could execute a drop trigger statement.

now i can not do it in my sql script file

do you have any idea about using it in an sql script ?

thanks
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34671
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by raminaa niilian:
do you have any idea about using it in an sql script ?

In a SQL script, we usually just do the drop unconditionally and ignore the errors about the table not being defined.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic