Re: TRIGGER truncates data.....
But I explicitly cast it as a char in the last part....why doesn't that work? Does it go to the table, see what the types should be, and THEN the trigger runs? There's no reason for @bar to be truncated in the example below.....is there?
from my post...
--------------------------------------------
I even tried this:
delimiter //
DROP TRIGGER insertIP //
CREATE TRIGGER insertIP BEFORE INSERT ON IPHistoryNum FOR EACH ROW
BEGIN set @bar=CAST(NEW.ip AS char); SET NEW.ip = INET_ATON(NEW.ip); SET @foo=NEW.ip; END;//
delimiter ;
mysql> insert into IPHistoryNum (ip) VALUES ('192.168.2.50') ;
Query OK, 1 row affected, 1 warnings (0.00 sec)
Warning (Code 1265): Data truncated for column 'ip' at row 1
mysql> select @bar,@foo;
+------+------+
| @bar | @foo |
+------+------+
| 255 | 255 |
+------+------+
1 row in set (0.00 sec)
mysql> select ip from IPHistoryNum;
+------------+
| ip |
+------------+
| 192 |
| 255 |
+------------+
Subject
Views
Written By
Posted
4342
May 08, 2006 01:51PM
1931
May 08, 2006 02:54PM
Re: TRIGGER truncates data.....
1969
May 08, 2006 08:05PM
1812
May 08, 2006 08:33PM
1938
May 08, 2006 08:50PM
1675
May 08, 2006 09:11PM
1834
May 08, 2006 09:14PM
1896
May 08, 2006 09:23PM
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.