1

I can't seem to find why this gives me an error. It can't use the variable 'art' in the loop. But when I just do

 select art;

It gives me the correct number of items.

    drop procedure if exists bepaal_lijst_van_bij_te_bestellen_artikelen;

    delimiter //
    create procedure bepaal_lijst_van_bij_te_bestellen_artikelen()
    begin
        DECLARE art INT;
        DECLARE i INT;

        SELECT @art := COUNT(artikel_id) FROM artikelen;

        SET i = 1;
        WHILE i <= art DO

        END WHILE;
    end;
    //

    delimiter ;
2
  • 2
    it hurts the eyes to read this bepaal_lijst_van_bij_te_bestellen_artikelen! was there nothing simpler to choose? Commented Mar 16, 2013 at 15:55
  • yes there is. it hurts me too :)... but my university says I have to take this procedure name. I'm sorry Commented Mar 16, 2013 at 15:56

3 Answers 3

1

I think you should do

SET art := SELECT COUNT(artikel_id) FROM artikelen
Sign up to request clarification or add additional context in comments.

1 Comment

This works now. SELECT @art := COUNT(artikel_id) FROM artikelen; SET doesn't work. However the while loop still doesn't want to fire up.
1

You could just do (note: I know how the assignment goes)

SELECT count(*) from Items into art;

Comments

1

Apparantly the while loop couldn't be empty and should contain something. fixed it by adding

SET i = 1 + i;

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.