Last answered:

22 May 2024

Posted on:

16 Feb 2023

0

Problem getting stored procedure to work

Hello, I'm unable to create the stored procedure. I have: SQL Error [1064] [42000]: 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 'delimiter' at line 7. 

3 answers ( 0 marked as helpful)
Instructor
Posted on:

17 Feb 2023

0

Hi Michelle!
Thanks for reaching out!


Could you please support your question with the entire code you’ve executed, as well as a screenshot containing the entire error message you’ve encountered? This can help us assist you better. Thank you.


Looking forward to your answer.
Best,
Tsvetelin

Posted on:

26 Feb 2023

0

# stored procedure to return the first 1000 rows from the 'employees' table:

use employees;

-- drop procedure if exists select_employees;

 

delimiter $$

create procedure select_employees()

begin

select * from employees

limit 1000;

END $$

 

delimiter ; -- this resets the semi-colon as a delimiter for further coding

 

# call the routine 

call employees.select_employees();

 

call select_employees();

Instructor
Posted on:

22 May 2024

0

Hi Michelle!

Thanks for reaching out!


It seems that this query is correct. In this situation, the error message is due to a missed semicolon (;) at the end of a previous query. So, adding it at the end of the query which misses it, will resolve the syntax error message.
 

Hope this helps.
Best,
Martin

Submit an answer