The CALL statement can return a value to its caller using parameters declared as OUT or INOUT parameters.
It also "returns" the number of affected rows, the client program can obtain this at the SQL level by calling the ROW_COUNT() function Number, obtained from C by calling the mysql_affected_rows() C API function. (Recommended learning: MySQL video tutorial)
Grammar notes:
1,MySQL 存储过程中的每条语句的末尾,都要加上分号 “;” ... declare c int; if a is null then set a = 0; end if; ... end; 2,注释是 -- ; MySQL 存储过程的参数不能指定默认值 3,不能在 MySQL 存储过程中使用 “return” 关键字。 set c = a + b; select c as sum; end; 4. 调用 MySQL 存储过程时候,需要在过程名字后面加“()”,即使没有一个参数,也需要“()” call pr_no_param(); 5. 因为 MySQL 存储过程参数没有默认值,所以在调用 MySQL 存储过程时候,不能省略参数。可以用 null 来替代。 call pr_add(10, null);
For more MySQL related technical articles, please visit MySQL tutorial column to learn!
The above is the detailed content of The function of the call statement is. For more information, please follow other related articles on the PHP Chinese website!