Solved

MYSQL Syntax Error

Posted on 2013-05-18
1
428 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

691 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