Using buildin function in user-defined function : Function « Procedure Function « MySQL Tutorial






mysql>
mysql> DELIMITER //
mysql>
mysql> CREATE FUNCTION myFunction (item_sum DECIMAL(10,2))
    -> RETURNS DECIMAL(10,1)
    -> BEGIN
    ->
    ->
    -> RETURN ROUND(item_sum,1);
    ->
    -> END
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql> DELIMITER ;
mysql>
mysql> select myFunction(123.12);
+--------------------+
| myFunction(123.12) |
+--------------------+
|              123.1 |
+--------------------+
1 row in set (0.02 sec)

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








11.3.Function
11.3.1.Creating Functions
11.3.2.A function that takes a parameter, performs an operation using an SQL function, and returns the result
11.3.3.Single statement function
11.3.4.Nested function call
11.3.5.Using buildin function in user-defined function
11.3.6.Changing and Removing Functions
11.3.7.To remove a stored function, use the DROP command
11.3.8.Create a procedure for 'READS SQL DATA'
11.3.9.ALTER PROCEDURE and ALTER FUNCTION Syntax
11.3.10.DROP PROCEDURE and DROP FUNCTION Syntax
11.3.11.Function Permissions