Re: Trigger for read-only column
Thanks Peter it's working now! But I can not update any of the fields. I want only the client_id to be locked.
mysql> delimiter //
mysql> CREATE TRIGGER client_id_lock BEFORE UPDATE ON users_column_lock
-> FOR EACH ROW
-> BEGIN
-> IF OLD.client_id THEN SIGNAL SQLSTATE '45000'
-> SET
-> MESSAGE_TEXT = 'Cannot update locked record';
-> END IF;
-> END;//
Query OK, 0 rows affected (0.11 sec)
update users_column_lock set client_id=20 where users_id=521;
ERROR 1644 (45000): Cannot update locked record
mysql> update users_column_lock set first_name='Fitsum' where users_id=521;
ERROR 1644 (45000): Cannot update locked record
Edited 2 time(s). Last edit at 06/12/2013 02:25PM by Fitsum Tesfagiorgis.
Subject
Views
Written By
Posted
2986
June 12, 2013 07:53AM
1818
June 12, 2013 09:25AM
Re: Trigger for read-only column
4371
June 12, 2013 01:57PM
1720
June 15, 2013 09:46AM
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.