» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > MySQL Forums

MySQL Forums Share Your Ideas and Tips about MYSQL. Ask questions about MYSQL. Table Design and Much More...

Reply
 
Thread Tools Display Modes
  #1  
Old 10-30-2006, 03:27 AM
Wrudra Wrudra is offline
Junior Member
 
Join Date: Oct 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Wrudra is on a distinguished road
Default error in SQL syntax!!

Hello all, I've some matters with triggers i.e.

CREATE TRIGGER maj_cumul BEFORE UPDATE ON planning
FOR EACH ROW
IF NEW.nbssc>nbssc THEN BEGIN
UPDATE prof SET nbc=nbc+NEW.nbssc WHERE planning.numprof=prof.numprof;
END;
ELSE
UPDATE prof SET nbc=nbc-NEW.nbssc WHERE planning.numprof=prof.numprof;
END;
END IF;

MySQL a réponduocumentation
#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 'UPDATE prof SET nbc=nbc+NEW.nbssc WHERE planning.numprof=prof.numprof' at line 4
Please help me to understand.
thank you. -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 10-30-2006, 03:31 AM
Yadira Yadira is offline
Senior Member
 
Join Date: Jul 2006
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 16
Yadira is on a distinguished road
Default

As per me the BEGIN/END statement should be around the entire body:

CREATE TRIGGER maj_cumul BEFORE UPDATE ON planning
FOR EACH ROW
BEGIN
IF NEW.nbssc>nbssc THEN
UPDATE prof SET nbc=nbc+NEW.nbssc WHERE planning.numprof=prof.numprof;
ELSE
UPDATE prof SET nbc=nbc-NEW.nbssc WHERE planning.numprof=prof.numprof;
END IF;
END

Dont know how phpMyAdmin works, but at the command line you need delimiter statements to tell the client not to process the input when it sees the first ;, but look for a different delimiter. On the command line it would look something like:


DELIMITER //

CREATE TRIGGER maj_cumul BEFORE UPDATE ON planning
FOR EACH ROW
BEGIN
IF NEW.nbssc>nbssc THEN
UPDATE prof SET nbc=nbc+NEW.nbssc WHERE planning.numprof=prof.numprof;
ELSE
UPDATE prof SET nbc=nbc-NEW.nbssc WHERE planning.numprof=prof.numprof;
END -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in SQL syntax! sullen MySQL Forums 1 12-18-2006 03:19 AM
sql syntax!! Hsierra MySQL Forums 1 11-04-2006 04:12 AM
error in SQL syntax!!! Mara MySQL Forums 1 08-19-2006 04:19 AM
DiscountASP.NET Launches SQL Database Transfer Tool outsourcingplans Web Hosting News 0 08-09-2006 03:23 AM
DiscountASP.NET Introduces New Services outsourcingplans Web Hosting News 0 08-08-2006 06:42 AM


All times are GMT. The time now is 01:56 PM.