Welcome to WebmasterWorld Guest from 54.167.76.176

Forum Moderators: open

Message Too Old, No Replies

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.

shmamy

3:36 am on Dec 15, 2012 (gmt 0)



[size=2][/size]I just changed the second section to:

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


Now my error is:

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 'END' at line 8

Peetter123

7:16 am on Dec 21, 2012 (gmt 0)



i also faced this kind of problem but i don't have any solution to this problem.Did you get any?

shmamy

2:42 am on Dec 23, 2012 (gmt 0)



I never did figure it out. I just ended up showing my teacher the code was correct but I got errors for what ever reason and I got the credit for it. I was using workbench, so I'm not sure if workbench just doesn't support it or requires it to be put in differently.

arms

1:01 pm on Dec 28, 2012 (gmt 0)



TRY:-

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;

pavanraj

7:10 am on Jan 4, 2013 (gmt 0)



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
/

Try this........
 

Featured Threads

Hot Threads This Week

Hot Threads This Month