Created
March 12, 2020 16:33
-
-
Save rstriquer/ad110c94bb873a7ab9a44cea705464c3 to your computer and use it in GitHub Desktop.
Exemplo de criação simples de procedures e funcions no mysql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELIMITER // | |
DROP FUNCTION IF EXISTS `TSTE_BVASE`// | |
CREATE FUNCTION `TSTE_BVASE`() RETURNS TINYINT | |
BEGIN | |
DECLARE agora DATETIME; | |
SET agora = now(); | |
IF @agora>now() THEN RETURN 1; | |
ELSE RETURN 0; | |
END IF; | |
END// | |
DELIMITER ; | |
SELECT TSTE_BVASE(); | |
DELIMITER // | |
DROP PROCEDURE simpleSample // | |
CREATE PROCEDURE simpleSample (OUT param1 INT) | |
BEGIN | |
SELECT COUNT(COLUMN_NAME) INTO param1 FROM INFORMATION_SCHEMA.COLUMNS LIMIT 1; | |
END// | |
DELIMITER ; | |
CALL simpleSample(@a); | |
SELECT @a; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment