On May 15, 2008, at 4:30 AM, rustam ershtukaev wrote:
I have been trying to write a trigger in mysql, but can't get it to
work. It's really simple,i just need my trigger to add varchar value
to
a table on insert if postcode = 1000.
Where does postcode come from? Your SELECT statement appears to have
no relation to the row to be inserted. It also appear that it will
always set v_postcode to 1000 if the departement table contains *any*
rows with a postcode of 1000.
this is how i did it:
delimiter |
drop trigger testdep|
create trigger testdep
before insert on departements
for each row
begin
declare v_postcode INTEGER;
declare v_place VARCHAR;
select departement_postcode
into v_postcode
from departement
where departement_postcode = 1000;
IF v_postcode = 1000 then
update departementen set departement_place = 'New York'
where departement_postcode = 1000;
END IF;
END|
but when i insert a new row i don't get my v_place value set
so if there someone who has time to help me with this i would greatly
appreciate this :)
--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
www.mysql.com
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]