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 8258623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:36:23+00:00 2026-06-08T02:36:23+00:00

i have such procedure but all the time i want to execute it i

  • 0

i have such procedure but all the time i want to execute it i get syntax error near declaring variables… can anybody tell me what i am doint wrong

i have two tables one for questions and one for answers and excel file to migrate data to this tables.
data in excel looks like this:

ID      N       TITLE
3       99500   question1
4       
5               answer1
6       X       answer2
7               answer3




 DELIMITER $$
create Procedure proc_answermigration()
begin

  DECLARE @i,@n,@q,@ind,@pt varchar default '';
  DECLARE @done,@aord int default 0;
  DECLARE cur cursor for select ID, N, question, from test.qustionmigration;
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET @done = 1;
  open cur;

  read_loop: Loop
  fetch cur into i,n,q;

  IF done THEN
  LEAVE read_loop;
  END IF;

  if n <> '' or n <> 'X'
    then
      select @ind = iq.question_id, @pt = iq.points from test.qustionmigration qm
      inner join ilias.qpl_questions iq on qm.question = iq.question_text
      where question = q
  else
      insert into qpl_a_sc
      (
        answer_id,
        question_fi,
        answertext,
        points,
        aorder,
        tstamp
      )
      select (select sequence from qpl_a_sc_seq),
              ind,
              question,
              pt,
              aord,
              '1342884200'
      from test.qustionmigration
      end if;

  update qpl_a_sc_seq
  set sequence = sequence + 1;

  if @aord = 0 then set @aord = 1;
  elseif @aord = 1 then set @aord = 2;
  else set @aord = 0;

  end loop;
  CLOSE cur;

end$$

DELIMITER ;

i corrected some statements but still it has syntax error saying:

#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 'LOOP; close cur; end' at line 52


DELIMITER $$
create Procedure proc_answermigration()
begin

  DECLARE i,n,q,ind,pt varchar(500) default '';
  DECLARE done,aord,c int default 0;
  DECLARE cur cursor for select ID, N, question from test.qustionmigration;
  DECLARE  CONTINUE HANDLER FOR NOT FOUND SET done = 1;

  open cur;


  read_loop: LOOP
    fetch cur into i,n,q;
    IF n <> '' or n <> 'X'
      then
        select ind = iq.question_id, pt = iq.points from test.qustionmigration qm
        inner join ilias.qpl_questions iq on qm.question = iq.question_text
        where question = q;
    else
        insert into qpl_a_sc
        (
          answer_id,
          question_fi,
          answertext,
          points,
          aorder,
          tstamp
        )
        select (select sequence from qpl_a_sc_seq),
                ind,
                question,
                pt,
                aord,
                '1342884200'
        from test.qustionmigration;
    end IF;

    update qpl_a_sc_seq
    set sequence = sequence + 1;

    if aord = 0 then set aord = 1;
    elseif aord = 1 then set aord = 2;
    else set aord = 0;

    set c = c + 1;


  IF done = 1 THEN
      LEAVE read_loop;
  END IF;

  END LOOP;

  close cur;
end$$
DELIMITER ;
  • 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-08T02:36:26+00:00Added an answer on June 8, 2026 at 2:36 am

    Your last IF ELSE block is missing its END IF:

    if @aord = 0 then set @aord = 1;
    elseif @aord = 1 then set @aord = 2;
    else set @aord = 0;
    /* END IF either belongs here or after following statements, depending on your intended logic */
    /* Either way, this block is unclosed when you close the loop */
    end if
    

    When the parser reads the END LOOP;, it is looking for the END IF, and reports a syntax error at LOOP.

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

Sidebar

Related Questions

Sorry if there is already made such question earlier, but I have no time
I have multiple models that I want to search such that the results can
I have a stored procedure which update a table based on such calculation and
Hello All I am using infragsitics tree view control.I have one stored procedure that
I have a stored procedure that is not only huge, but very memory intensive.
have such zend query: $select = $this->_table ->select() ->where('title LIKE ?', '%'.$searchWord.'%') ->where('description LIKE
i have such code (copy paste from wiki). Its multiplication of those big numbers
I have such XML structure which was returned by SharePoint web services. <rs:data ItemCount=4
i have such function to solve some logic riddle iloczyny is list with such
I have such a grid square disk. Every grid represents a pixel. My aim

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.