homepage Welcome to WebmasterWorld Guest from 54.166.65.9
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

    
SQL Syntax Error
shmamy




msg:4528309
 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




msg:4528312
 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




msg:4530123
 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




msg:4530527
 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




msg:4531699
 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




msg:4533154
 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........

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved