hi, i am trying to create this trigger using phpmyadmin, but it gives me an error:
------------------------------------------
CREATE TRIGGER receipts_before_insert BEFORE INSERT ON receipts
FOR EACH ROW BEGIN
DECLARE m_vat_period_year INT;
DECLARE m_vat_period_month INT;
SELECT current_vat_period_year, current_vat_period_month INTO m_vat_period_year, m_vat_period_month FROM companies WHERE key_id = NEW.companies_key_id;
SET NEW.vat_period_year = YEAR(NEW.receipt_date);
SET NEW.vat_period_month = MONTH(NEW.receipt_date);
IF (m_vat_period_year * 100) + m_vat_period_month > (YEAR(NEW.receipt_date) * 100) + MONTH(NEW.receipt_date) THEN
SET NEW.vat_period_year = m_vat_period_year;
SET NEW.vat_period_month = m_vat_period_month;
END IF;
--------------------------------
the error it gives is: "#1064 - 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 'INT' at line 3 "
i am new to triggers and procedures, can anybody help how to create this trigger...
thx in advance
http://www.mqdev.com