Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- SQL Syntax Error


shmamy - 3:26 am on Dec 15, 2012 (gmt 0)


CREATE TABLE CHANGES
(USER CHAR(20) NOT NULL,
CHA_TIME TIMESTAMP NOT NULL,
CHA_ISBN CHAR(20) NOT NULL,
CHA_TYPE CHAR(1) NOT NULL,
CHA_ISBN_NEW CHAR(20),
PRIMARY KEY(USER, CHA_TIME, CHA_ISBN, CHA_TYPE))

CREATE TRIGGER INSERT BOOK_INFO
AFTER
INSERT ON BOOK_INFO FOR EACH ROW
BEGIN
INSERT INTO CHANGES
(USER, CHA_TIME, CHA_ISBN, CHA_TYPE, CHA_ISBN_NEW)
VALUES(USER, CURDATE(), NEW.ISBN, 'I', NULL);
END


syntax error: unexpected end

My book says to put the ';' in but when I do I get an unexpected end. When I don't put it I get this:

Error Code: 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 'INSERT BOOK_INFO AFTER INSERT ON BOOK_INFO FOR EACH ROW BEGIN INSERT INTO' at line 1

I'm stuck and can't figure out where my error is.


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/4528307.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com