Verify the input parameter : Parameters « Procedure Function « MySQL Tutorial






mysql>
mysql> delimiter $$
mysql>
mysql> CREATE FUNCTION myFunction (in_string varchar(80) )
    ->  RETURNS VARCHAR(256)
    ->  NO SQL
    -> BEGIN
    ->    DECLARE i INT DEFAULT 1;
    ->       DECLARE string_len INT;
    ->       DECLARE out_string VARCHAR(256) DEFAULT '';
    ->
    ->       SET string_len=length(in_string);
    ->       WHILE (i<string_len) DO
    ->          SET out_string=CONCAT(out_string,ASCII(substr(in_string,i,1)),' ');
    ->          SET i=i+1;
    ->       END WHILE;
    ->       RETURN (out_string);
    ->
    -> END$$
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> delimiter ;
mysql>
mysql> select myFunction('ABCDEFGHI');
+--------------------------+
| myFunction('ABCDEFGHI')  |
+--------------------------+
| 65 66 67 68 69 70 71 72  |
+--------------------------+
1 row in set (0.00 sec)

mysql>
mysql> drop function myFunction;
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql>








11.7.Parameters
11.7.1.DateTime parameter
11.7.2.Verify the input parameter
11.7.3.Check input parameter
11.7.4.Declare and use the OUT parameter
11.7.5.Save status to an OUT parameter
11.7.6.Pass status code and message out of a procedure
11.7.7.Using OUT parameter to return the status code and message from a procedure
11.7.8.Pass variable to a procedure as the OUT parameter