can we create an event inside MySQL stored procedure? i tried creating event scheduler inside MySQL stored procedure ,but event is not created
2 Answers
Restrictions on Stored Programs
Generally, statements not permitted in SQL prepared statements are also not permitted in stored programs. ... Exceptions are SIGNAL, RESIGNAL, and GET DIAGNOSTICS, which are not permissible as prepared statements but are permitted in stored programs.
There is NO CREATE EVENT
in "SQL Syntax Allowed in Prepared Statements" list.
An attempt to create procedure which tries to create event causes
ERROR 1576 (HY000): Recursion of EVENT DDL statements is forbidden when body is present.

- 39,301
- 5
- 14
- 25
-
so we cant create event inside stored program? – Tech_Delhi Jun 05 '20 at 08:59
-
@v_Techie Yes, that's true. But you may create inactive event beforehand and enable it in stored procedure. – Akina Jun 05 '20 at 09:16
MYSQL documentation has not been updated even in v8 to remove the inconsistency between https://dev.mysql.com/doc/refman/8.0/en/create-event.html which states in the last sentence 'You can create an event as part of a stored routine, but an event cannot be created by another event.' and https://dev.mysql.com/doc/refman/8.0/en/stored-program-restrictions.html under EVENT RESTRICTIONS which states 'An event may not be created, altered, or dropped from within a stored program' - the latter being the correct statement.

- 17,104
- 2
- 12
- 19