MySQL updating a field to result of a function
- by jdborg
mysql> CREATE FUNCTION test ()
    -> RETURNS CHAR(16)
    -> NOT DETERMINISTIC
    -> BEGIN
    -> RETURN 'IWantThisText';
    -> END$$
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT test();
+------------------+
|    test()        |
+------------------+
| IWantThisText    | 
+------------------+
1 row in set (0.00 sec)
mysql> UPDATE `table`
    -> SET field = test()
    -> WHERE id = 1
Query OK, 1 row affected, 1 warning (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 1
mysql> SHOW WARNINGS;
+---------+------+----------------------------------------------------------------+
| Level   | Code | Message                                                        |
+---------+------+----------------------------------------------------------------+
| Warning | 1265 | Data truncated for column 'test' at row 1                      | 
+---------+------+----------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT field FROM table WHERE id = 1;
+------------------+
| field            |
+------------------+
| NULL             | 
+------------------+
1 row in set (0.00 sec)
What I am doing wrong?  I just want field to be set to the returned value of test()
Forgot to mention field is VARCHR(255)