Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8997711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:55:34+00:00 2026-06-15T23:55:34+00:00

I run this code as a sql script from command line, and I get

  • 0

I run this code as a sql script from command line, and I get “you have an error in your SQL syntax” almost in all lines! Any ideas what is wrong here?

CREATE PROCEDURE updatemandate()
 BEGIN
   DECLARE _mandate_id BIGINT(20);
   DECLARE _has_succesful_payment tinyint(1);
   DECLARE done INT DEFAULT 0;
   DECLARE cnt INT;
   DECLARE mandateCursor CURSOR FOR Select mandate_id, has_succesful_payment From mandates;
   DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; 
   OPEN mandateCursor;
   allmandates: LOOP
   Fetch mandateCursor INTO _mandate_id, _has_succesful_payment;
   IF done THEN LEAVE allmandates;
   END IF;
    Select COUNT(*) FROM payments WHERE mandate_id=_mandate_id AND status='OK' into cnt; 
            IF cnt>0 THEN
            SET _has_succesful_payment=1;
            END IF;

   END LOOP allmandates;
   CLOSE mandateCursor;
 END
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:55:35+00:00Added an answer on June 15, 2026 at 11:55 pm

    The ; character is the default delimiter, so when MySQL sees the first ; it thinks you are done. When you create a sproc, you need to declare a different delimiter character, like so:

    DELIMITER $$
    
    CREATE PROCEDURE updatemandate()
    READS SQL DATA
     BEGIN
       DECLARE _mandate_id BIGINT(20);
       DECLARE _has_succesful_payment tinyint(1);
       DECLARE done INT DEFAULT 0;
       DECLARE cnt INT;
       DECLARE mandateCursor CURSOR FOR Select mandate_id, has_succesful_payment From mandates;
       DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; 
       OPEN mandateCursor;
       allmandates: LOOP
       Fetch mandateCursor INTO _mandate_id, _has_succesful_payment;
       IF done THEN LEAVE allmandates;
       END IF;
        Select COUNT(*) FROM payment WHERE mandate_id=_mandate_id AND status='OK' into cnt; 
                IF cnt>0 THEN
                SET _has_succesful_payment=1;
                END IF;
    
       END LOOP allmandates;
       CLOSE mandateCursor;
     END$$
    
    DELIMITER ;
    

    Also a good idea to add the READS SQL DATA to the sproc definition in case you need to support binary logging.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I run this code to call the Google API, all I get is
I run this code here <html> <script type=text/javascript src=lib/jquery-ui-1.8.21.custom.min.js></script> <script src=http://127.0.0.1:5984/_utils/script/jquery.couch.js></script> <!--<script type=text/javascript src=lib/jquery-1.7.2.js></script>-->
I'm trying to run this code but this error appear: Uncaught TypeError: string is
When I run this code url = ('http://maps.google.com/maps/nav?'+ 'q=from%3A'+from_address+ '+to%3A'+to_address+ '&output=json&oe=utf8&key='+api_key) request = urllib2.Request(url)
What is the best way to run an external sql script from within a
I need to run a sql script that is in a file from my
Getting this error when I try to run this script. I'm creating the function
hi have this code which works perfectly with just value: <script type=text/javascript> $(document).ready(function() {
Is there a way to detect missing command line parameters from the oracle script
If I have a SQL script stored in a variable like this: DECLARE @SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.