开发者

Constants in the triggers in MySQL

开发者 https://www.devze.com 2023-04-02 10:43 出处:网络
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 maint

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;)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号