2010-01-14 101 views
1
mysql> desc test; 
+-------+------------------+------+-----+---------+----------------+ 
| Field | Type    | Null | Key | Default | Extra   | 
+-------+------------------+------+-----+---------+----------------+ 
| id | int(10) unsigned | NO | PRI | NULL | auto_increment | 
| a  | int(10) unsigned | NO |  | NULL |    | 
| b  | int(10) unsigned | NO |  | NULL |    | 
| c  | int(10) unsigned | NO |  | NULL |    | 
| str | varchar(9)  | YES |  | NULL |    | 
+-------+------------------+------+-----+---------+----------------+ 
5 rows in set (0.00 sec) 

mysql> CREATE TRIGGER Capitalize BEFORE INSERT ON test 
    -> SET NEW.str = UPPER(NEW.str) 
    -> ; 
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET NEW.str = UPPER(NEW.str)' at line 2 
mysql> 

我下面這樣的回答: How to define a column that can automate capitalizing?爲什麼我的觸發器不能在MySQL中工作?

回答

0
CREATE TRIGGER Capitalize BEFORE INSERT ON test 
FOR EACH ROW 
    SET NEW.str = UPPER(NEW.str); 

聽取意見的錯誤信息:「check the manual對應於你的MySQL服務器版本的使用權語法。」

相關問題