In Oracle there is PL/SQL, a powerful imperative language. Is there anything similar for MySQL?
I don't know how powerful they are, but this site gives information on writing MySQL stored procedures with SQL;
http://www.mysqltutorial.org/mysql-stored-procedure-tutorial.aspx
E.g.
http://www.mysqltutorial.org/sql-cursor-in-stored-procedures.aspx