3

I need to create an event inside a procedure, I read somewhere that it's possible but I don't know the syntax. I'm trying:

CREATE PROCEDURE DUMMY_PROCEDURE() 
BEGIN 
CREATE event e on schedule every 1 second DO 
INSERT INTO test.t values (current_timestamp); 
END; 

But it throws:

Any ideas on how to do this?, thanks for reading.

'#1576 - Recursion of EVENT DDL statements is forbidden when body is present

Edit1:
The reason I want to create an event within an event procedure is because it acts as an expiration date, so the function is executed an event with very specific parameters is also created, so when the expiration date arrives, automatically bank makes a particular action. Understand?

richardaum
  • 6,651
  • 12
  • 48
  • 64
  • Which version of mysql is this ? – Wadih M. Dec 02 '11 at 13:43
  • 1
    I just tried looking up your error and found http://forums.mysql.com/read.php?119,392941,392941 on the MySQL forum, which is a post exactly the same as this but made in 2010. How long have you had this problem Richard? – Sean H Jenkins Dec 02 '11 at 13:45
  • 5.1 and I did not wrote it in 2010. – richardaum Dec 02 '11 at 14:07
  • 1
    Instead of trying to create a new procedure each time, you can approach it differently. Create a procedure DUMMY_PROCEDURE() once that runs every X amount of time, and have it look at a table to decide what to do. Then, you can use this table to control its behavior. – Wadih M. Dec 02 '11 at 14:35

1 Answers1

3

You can't create an event inside procedure body. See this http://www.peregrinesalon.com/wp-content/uploads/2009/03/mysql-stored-procedures.pdf

Rahul
  • 76,197
  • 13
  • 71
  • 125
  • what's that you are trying to achive? you can have the procedure separately and call it with the event – Rahul Dec 02 '11 at 14:09
  • 2
    The reason I want to create an event within an event procedure is because it acts as an expiration date, so the function is executed an event with very specific parameters is also created, so when the expiration date arrives, automatically bank makes a particular action. Understand? – richardaum Dec 02 '11 at 14:17
  • Is this still true in mariadb ? Current version is 10.5 – Freedo May 06 '22 at 05:06