# Cannot create a stored procedure

**URL:** <https://forum.codewithmosh.com/t/cannot-create-a-stored-procedure/1494>\
**Category:** SQL\
**Created:** [December 28, 2020, 1:00am UTC](https://forum.codewithmosh.com/t/cannot-create-a-stored-procedure/1494 "2020-12-28T01:00:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![toasty](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@toasty](https://forum.codewithmosh.com/u/toasty)\
**Post date:** [December 28, 2020, 1:00am UTC](https://forum.codewithmosh.com/t/cannot-create-a-stored-procedure/1494/1 "2020-12-28T01:00:32Z")

</div>

In the Complete SQL Mastery course, under the Stored Procedures section, 2- Creating a Stored Procedure:

I was able to successfully create the stored procedure provided in the lesson called: get\_clients()

But, for some reason, creating another stored procedure does not work. In this case, I tried to create the procedure listed in the code below, used for the Exercise part of the lesson. But nothing happens when I run it. The stored procedure is not created and no error message appears in the Output window. Can someone help me understand what I’m doing wrong, please?

DELIMITER $$  
CREATE PROCEDURE get\_invoices\_with\_balance()  
BEGIN  
SELECT \*  
FROM invoices\_with\_balance  
WHERE balance \> 0;  
END$$

DELIMITER ;

---

<div class="post-metadata">

**Author:** ![NicolasATC](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/nicolasatc/32/714_2.png) [@NicolasATC](https://forum.codewithmosh.com/u/NicolasATC)\
**Post date:** [January 20, 2021, 3:40pm UTC](https://forum.codewithmosh.com/t/cannot-create-a-stored-procedure/1494/2 "2021-01-20T15:40:49Z")

</div>

Remember to update the views. Mosh does it everytime a new View or Procedure is created.

Also check if there are errors, and share them.

---

<div class="post-metadata">

**Author:** ![toasty](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@toasty](https://forum.codewithmosh.com/u/toasty)\
**Post date:** [January 24, 2021, 1:25am UTC](https://forum.codewithmosh.com/t/cannot-create-a-stored-procedure/1494/3 "2021-01-24T01:25:12Z")

</div>

Ah, I figured it out! The problem was with the comments I added. My example (above) doesn’t show them, but here’s what my code actually looked like (using double dashes):

DELIMITER $$ – resets the default delimiter to $$ instead of ;  
CREATE PROCEDURE get\_invoices\_with\_balance()  
BEGIN  
SELECT \*  
FROM invoices\_with\_balance  
WHERE balance \> 0;  
END$$

DELIMITER ; – sets the default delimiter back to ;

…so, MySQL doesn’t like those comments!! Yet. it did NOT report any ERRORS???

Anyway, after removing the 2 comments above, the stored procedure was created successfully!

---

<div class="post-metadata">

**Author:** ![NicolasATC](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/nicolasatc/32/714_2.png) [@NicolasATC](https://forum.codewithmosh.com/u/NicolasATC)\
**Post date:** [January 24, 2021, 3:25am UTC](https://forum.codewithmosh.com/t/cannot-create-a-stored-procedure/1494/4 "2021-01-24T03:25:14Z")

</div>

To avoid problems, put your comments on a new line.

```
DELIMITER $$ 
-– resets the default delimiter to $$ instead of ;
CREATE PROCEDURE get_invoices_with_balance()...
```

---

<div class="post-metadata">

**Author:** ![toasty](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@toasty](https://forum.codewithmosh.com/u/toasty)\
**Post date:** [January 24, 2021, 4:06am UTC](https://forum.codewithmosh.com/t/cannot-create-a-stored-procedure/1494/5 "2021-01-24T04:06:27Z")

</div>

That’s awesome. Thanks, NicolasATC!
