Re: IF / THAN in tiggers not working on 5.0.13-rc-nt-log ?
Waddaya mean, 'not work'? isnt the trigger fired? when you update a row? Or could you not get mysql to compile?
delimiter //
CREATE TABLE account (acct_num INT, amount DECIMAL(10,2))
//
CREATE TRIGGER upd_check BEFORE UPDATE ON account
FOR EACH ROW
BEGIN
IF NEW.amount < 0 THEN
SET NEW.amount = 0;
END IF;
END
//
mysql> insert into account values (1,-1);
-> //
Query OK, 1 row affected (0.05 sec)
mysql> select * from account
-> //
+----------+--------+
| acct_num | amount |
+----------+--------+
| 1 | -1.00 |
+----------+--------+
1 row in set (0.02 sec)
mysql> update account set amount = -2
-> //
Query OK, 1 row affected (0.06 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from account
-> //
+----------+--------+
| acct_num | amount |
+----------+--------+
| 1 | 0.00 |
+----------+--------+
1 row in set (0.00 sec)
mysql> select version()
-> //
+--------------+
| version() |
+--------------+
| 5.0.13-rc-nt |
+--------------+
1 row in set (0.00 sec)
As you can see, it works for me.
Subject
Views
Written By
Posted
2759
October 22, 2005 05:31PM
Re: IF / THAN in tiggers not working on 5.0.13-rc-nt-log ?
1880
October 23, 2005 01:54AM
1799
October 23, 2005 03:04AM
1766
October 23, 2005 05:34AM
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.