0

can we create an event inside MySQL stored procedure? i tried creating event scheduler inside MySQL stored procedure ,but event is not created

2 Answers2

0

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.

Prepared Statements

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.

Akina
  • 39,301
  • 5
  • 14
  • 25
0

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.

P.Salmon
  • 17,104
  • 2
  • 12
  • 19