A function that takes a parameter, performs an operation using an SQL function, and returns the result : Function « Procedure Function « SQL / MySQL






A function that takes a parameter, performs an operation using an SQL function, and returns the result

    
mysql>
mysql>
mysql> CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)
    ->     RETURN CONCAT('Hello, ',s,'!');
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql>
mysql> SELECT hello('world');
+----------------+
| hello('world') |
+----------------+
| Hello, world!  |
+----------------+
1 row in set (0.00 sec)

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

mysql>
mysql>

          
    
    
  








Related examples in the same category

1.Creating Functions
2.Single statement function
3.Nested function call
4.Using buildin function in user-defined function
5.To remove a stored function, use the DROP command
6.Create a procedure for 'READS SQL DATA'
7.Math calculation in a function
8.Function to shorten a string
9.Calculate number of day