Skip to content

Instantly share code, notes, and snippets.

@skihero
Created March 17, 2011 11:47
Show Gist options
  • Save skihero/874195 to your computer and use it in GitHub Desktop.
Save skihero/874195 to your computer and use it in GitHub Desktop.
create stored procedure in mysql
# set the delimiter to // to avoid confusion with the ; in the procedure body
delimiter //
CREATE PROCEDURE people()
BEGIN
SELECT user, host, password from mysql.user ;
END //
# To see the procedures
SELECT ROUTINE_NAME
FROM INFORMATION_SCHEMA.ROUTINES;
# To call the procedure
call people () ;
CREATE PROCEDURE procedures() BEGIN SELECT ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES; END //
# I use this to find the DN associated with a login_name
CREATE PROCEDURE find_common()
BEGIN SELECT enterprise.DN from enterprise, users where enterprise.entr_id = users.entr_id and users.login_name=login_name ; END //
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment