2、存储过程没返回值,参数可以是 IN,OUT,IN OUT类型,有的人可能会理解成OUT 也算是返回值。
3、调用方式:函数 select my_fun() 过程 call my_pro( )
4、DEMO
mysql>call my_pro(1,2,@c)
Query OK, 0 rows affected (0.00 sec)
mysql>select @c
+------+
| @c |
+------+
|3 |
+------+
1 row in set (0.00 sec)
mysql>select my_fun(1,2)
+-------------+
| my_fun(1,2) |
+-------------+
| 3 |
+-------------+
1 row in set (0.00 sec)
mysql>CREATE FUNCTION HelloWorld4()
->RETURNS VARCHAR(20)
->BEGIN
-> RETURN 'Hello World!'
->END
->//
Query OK, 0 rows affected (0.00 sec)
mysql>select HelloWorld4() //
+---------------+
| HelloWorld4() |
+---------------+
| Hello World! |
+---------------+
1 row in set (0.00 sec) ...展开mysql>CREATE FUNCTION HelloWorld4()
->RETURNS VARCHAR(20)
->BEGIN
-> RETURN 'Hello World!'
->END
->//
Query OK, 0 rows affected (0.00 sec)
mysql>select HelloWorld4() //
+---------------+
| HelloWorld4() |
+---------------+
| Hello World! |
+---------------+
1 row in set (0.00 sec)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)