MySQL Forums
Forum List  »  Triggers

problem with importing triggers
Posted by: mahfooz haq
Date: September 26, 2010 12:03PM

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

Options: ReplyQuote


Subject
Views
Written By
Posted
problem with importing triggers
2079
September 26, 2010 12:03PM
1472
September 27, 2010 01:15AM
1096
September 27, 2010 01:51AM
1038
September 27, 2010 02:32AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.