/ Published in: SQL
Before calling the PROCEDUREs you created, use `SHOW PROCEDURE status;` to confirm.
To use these procedure, use the script like `CALL hello();` and `CALL globalHello('EN');`
To use these procedure, use the script like `CALL hello();` and `CALL globalHello('EN');`
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
DELIMITER $$ DROP PROCEDURE IF EXISTS `hello` $$ CREATE PROCEDURE `hello`() SQL SECURITY DEFINER COMMENT 'Hello World!' BEGIN DECLARE str VARCHAR(50); SET str = 'ä½ å¥½ï¼'; SELECT str AS 'HELLO'; END $$ DROP PROCEDURE IF EXISTS `globalHello` $$ CREATE PROCEDURE `globalHello`(IN lang VARCHAR(10)) COMMENT 'Say hello with multi-language' BEGIN DECLARE str VARCHAR(50); SET lang = LOWER(TRIM(lang)); CASE lang WHEN 'zh' THEN SET str = 'ä½ å¥½ï¼'; WHEN 'en' THEN SET str = 'Hello!'; ELSE SET str = '[Hello]!'; END CASE; SELECT str AS 'HELLOWORLD' ; END $$ DELIMITER ;