MySQL Forums
Forum List  »  Triggers

Trigger question
Posted by: personal private
Date: October 06, 2014 09:42AM

I know this question has been asked before, but my Google foo is failing me.

I want to make a trigger like the following:
Begin
if NEW.string_field LIKE "string litteral" THEN
***THis is my issue**
I need to reject the insert and respond with a message like
"string_field must not be the default value."
end if
end

(Obviously the semi colons are missing from the example)

Use case: In a data base we have a 'comment' column. This column stores information which is both a comment, and to help people using software which uses the database to understand what material they are selecting. The field has a default value of "Enter an end user useful comment here, to serve as a description". If a new record is added, and the field has not been changed, I need it to kick out a message that the person entering the data will see, and refuse to write the data.

So question 1:
Can this be done from a trigger?

Question 2:
(If Q1 is true) Can this be done without creating a custom exception? (please provide example as I am new to MySQL triggers/roputines/functions)

Question 3:
(If Q2 is false) How do create and use a custom exception for this (hopefully from the trigger) (If I have to go this route I have no idea how to, so please provide an example or a link to an example....)?

Any help would be appreciated.
C. Jason B.

Options: ReplyQuote


Subject
Views
Written By
Posted
Trigger question
2349
October 06, 2014 09:42AM
1045
October 06, 2014 11:17AM


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.