mardi 19 juillet 2016

Execute arbitrary procedural code in MySQL/MariaDB

In T-SQL, I can declare variables and otherwise write any procedural code I wish inside or outside of a stored procedure. In PostgreSQL, I can say something like…

DO $$
DECLARE foo INT DEFAULT 0;
BEGIN
  -- Blah blah
END;
$$;

And this executes some arbitrary procedural code. Is there anything like this in MySQL or do I have to create a "throwaway" stored procedure? (That's not the end of the world for my use case, but I'm curious if there's a better way.)

Aucun commentaire:

Enregistrer un commentaire