Issues creating trigger in MySQL 5.0.27 - SOLVED
Posted: Tue Jun 19, 2007 11:41 am
I'm having issues creating the following trigger:
If I enter it into the MySQL console, I get this error:
I built that code based on the example used on what I found in the MySQL docs here: http://dev.mysql.com/doc/refman/5.0/en/ ... igger.html
Near as I can tell, my code is identical to their example with the exception of table names... any ideas?
If it helps, here are the table definitions:
login:
contact:
-Dex
EDIT:
If I can't get this trigger to work, I'm just gonna end up doing the equivalent in PHP. I'd rather have the database take care of it, though.
Code: Select all
create trigger login_to_con after insert on login
for each row begin
insert into contact set con_name = new.co_name;
end;Code: Select all
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 'insert
into contact set con_name = new.co_name' at line 3Near as I can tell, my code is identical to their example with the exception of table names... any ideas?
If it helps, here are the table definitions:
login:
Code: Select all
+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| co_name | varchar(255) | NO | PRI | | |
| pass | varchar(255) | NO | | | |
| admin_email | varchar(255) | NO | | | |
+-------------+--------------+------+-----+---------+-------+Code: Select all
+----------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+------------------+------+-----+---------+-------+
| con_id | int(10) unsigned | NO | PRI | | |
| con_name | varchar(255) | NO | MUL | | |
| email | varchar(255) | YES | | NULL | |
| phone | varchar(15) | YES | | NULL | |
| fax | varchar(15) | YES | | NULL | |
+----------+------------------+------+-----+---------+-------+-Dex
EDIT:
If I can't get this trigger to work, I'm just gonna end up doing the equivalent in PHP. I'd rather have the database take care of it, though.