Solved

MYSQL Syntax Error

Posted on 2013-05-18
1
424 Views
Last Modified: 2013-05-18
Hi

I get an "unexpected END_OF_INPUT, expected IF" error on the following MYSQL statement , can anyone help please

delimiter //

CREATE PROCEDURE UPDuserdaily (IN P_UserID INT,IN P_UserDate DATETIME)
BEGIN
      IF NOT EXISTS (SELECT 1 FROM tbuserdaily WHERE UserID=P_UserID AND Date=P_UserDate) THEN
            INSERT tbuserdaily(UserID,Date) VALUES (P_UserID,P_UserDate);
      
      UPDATE tbuserdaily
      SET Distance = (SELECT SUM(Distance) FROM tbjourney
                              WHERE UserID=P_UserID AND JourneyDateDate=P_UserDate)
      WHERE UserID=P_UserID AND Date=P_UserDate;

END//

DELIMITER ;
0
Comment
Question by:prices1964
1 Comment
 
LVL 14

Accepted Solution

by:
Juan Ocasio earned 500 total points
ID: 39177136
Try ending the IF with an END IF

delimiter //

CREATE PROCEDURE UPDuserdaily (IN P_UserID INT,IN P_UserDate DATETIME)
BEGIN
      IF NOT EXISTS (SELECT 1 FROM tbuserdaily WHERE UserID=P_UserID AND Date=P_UserDate) THEN
            INSERT tbuserdaily(UserID,Date) VALUES (P_UserID,P_UserDate);
      
      UPDATE tbuserdaily
      SET Distance = (SELECT SUM(Distance) FROM tbjourney
                              WHERE UserID=P_UserID AND JourneyDateDate=P_UserDate)
      WHERE UserID=P_UserID AND Date=P_UserDate;
      END IF;
END//

DELIMITER ; 

Open in new window

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now