DELIMITER $$ CREATE PROCEDURE getPercentage() BEGIN SELECT (COUNT(fault_resolved)/ count(id)*100)AS percent FROM log; END$$ DELIMITER ;
Note: The DELIMITER $$ exists to change the delimiter used, which is normally ;
This means we can have our statement inside and using a ; but will not be seen as the end of the statement.
This can be called by
CALL getPercentage();
This can be dropped by
DROP PROCEDURE getPercentage();
OR
DROP PROCEDURE IF EXISTS getPercentage();
To show procedure status;
SHOW PROCEDURE STATUS ;
OR to search for a procedure;
SHOW PROCEDURE STATUS LIKE '%per%'
TODO
Alter stored procedure
parameters
PostgreSQL
PHP example using storied procedure
No comments:
Post a Comment
Note: only a member of this blog may post a comment.