Constants in the triggers in MySQL
I'm trying to create a trigger in MySQL. I need to use some values (constants) at several times within the trigger. How can I define a constant in order t开发者_运维知识库o make my trigger more maintainable and don't have numeric values spread along the code.
(Maybe is an stupid question but I'm a starter with MySQL)
Thanks in advance
As NullUserException stated, DECLARE is what you need. (The syntax he indicated is wrong however).
The syntax is
DECLARE var_name type DEFAULT value;
example
DECLARE someConstant int DEFAULT 10;
if you leave off DEFAULT the initial value will be NULL. (IE: DECLARE var_name type;)
精彩评论