Can I use a mysql trigger to control the update of a field if it has a value?

Source: Internet
Author: User
Mysql trigger problems can I use a trigger to control whether a field will reject update once it has a value. one of the 200 fields in table t1 is f1.

When a record is inserted into table t1, the f1 field must be null.

An update changes the f1 field to the current timestamp.

After that Can you control all update statements for this record? once the statement updates this field value, the update is denied.

Whether to use a trigger or other methods. what should I do if I can use a trigger?>


Reply to discussion (solution)

Create trigger upd_check before update on t1 for each row begin if not isnull f1 then set new. f1 = f1; end if; END;

Thanks to xu da'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.