CALL¶
调用 存储过程。
语法¶
必填参数¶
procedure_name ( [ [ arg_name => ] arg , ... ] )指定要调用的过程的标识符 (
procedure_name) 和任何输入实参。您可以按名称 (
arg_name => arg) 或位置 (arg) 指定输入实参。备注
必须按名称或位置指定所有实参。不能按名称指定某些实参,也不能按位置指定其他实参。
When you specify an argument by name, you can't use double quotes around the argument name.
If two procedures have the same name but different argument types, you can use the argument names to specify which procedure to execute, if the argument names are different. For more information, see 重载过程和函数.
可选参数¶
INTO :snowflake_scripting_variable将指定的 Snowflake Scripting 变量 设置为存储过程的返回值。
示例¶
有关创建和调用存储过程的更多示例,请参阅 使用存储过程。
存储过程的每个实参都可以是通用表达式:
实参可以是子查询:
每个 CALL 语句只能调用一个存储过程。例如,以下语句失败:
此外,不能将存储过程 CALL 用作表达式的一部分。例如,以下所有语句都失败:
但是,在存储过程中,存储过程可以调用另一个存储过程,也可以以递归方式调用自身。
小心
嵌套调用可能会超过允许的最大堆栈深度,因此在嵌套调用时要小心,尤其是在使用递归时。
以下示例调用名为 sv_proc1 的存储过程,并传入字符串字面量和数字作为输入实参。此示例按位置指定实参:
您还可以按其名称指定实参:
以下示例演示如何设置 会话变量 并将其作为输入实参传递给存储过程:
以下是 Snowflake Scripting 块的示例,该块获取 Snowflake Scripting 变量中存储过程的返回值。
Note: If you use Snowflake CLI, SnowSQL, the Classic Console, or the
execute_stream or execute_string method in Python Connector
code, use this example instead (see Using Snowflake Scripting in Snowflake CLI, SnowSQL, and Python Connector):