0

ERROR -


Error

SQL query:

call cursorproc(
@p_out
);

MySQL said: Documentation

1329 - No data - zero rows fetched, selected, or processed


AFTER EXECUTING - called stored procedure

call cursorproc (@p_out);
select @p_out as temp;

FOLLOWING CODE EXECUTED SUCCESSFULLY - stored procedure

create procedure cursorproc(OUT p_out DECIMAL(10,2))
begin

   declare l_salary, l_total DECIMAL(10,2);

   declare cur_1 cursor for select line_distance from elements;
   
   open cur_1;

   set l_total = 0;

   loop

      fetch cur_1 into l_salary;

      
         set l_total = l_total + l_salary;
      
  end loop;

   close cur_1;

   set p_out = l_total;

end;

Any solution to this where exactly we are missing? Help on this would be appreciated.

1 Answer 1

1

You should check end of dataset while reading data. Have a look at example here - cursors.

Also, I'd suggest you to avoid opening cursor -

SELECT SUM(line_distance) INTO @var FROM  elements;
SELECT @var;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.