<budget_ name>!ADD_ CUSTOM_ ACTION¶
Associates a stored procedure with a budget so that the procedure is called when projected or actual spending reaches a specified threshold. The procedure must be associated by reference.
For more information, see Custom actions for budgets.
语法
实参
'stored_procedure_reference'The serialized string representation that resolves to a procedure. This string is the output of the SYSTEM$REFERENCE function.
reference_statementA SYSTEM$REFERENCE statement that creates a reference for the procedure to be associated with the budget.
array_of_arguments要传递给存储过程的实参数组。
array_construct_statementAn ARRAY_CONSTRUCT statement that returns an array constructed from zero, one, or more inputs.
{ 'ACTUAL' | 'PROJECTED'}控制操作是基于实际支出还是预计支出触发。
'ACTUAL'— The stored procedure is called when the actual spend reaches thethreshold.'PROJECTED— The stored procedure is called when spending is projected to reach thethreshold.If omitted, defaults to
PROJECTED.threshold预算限额的百分比。当 Snowflake 判定实际或预计支出超过此预算限额百分比时,将调用该存储过程。
请指定一个介于 0 到 1,000 之间(含 0 和 1,000)的数字。
返回
返回一个 VARCHAR 值,用于指明过程是否已成功与预算相关联。
如果无法将过程与预算关联,该方法将返回一条错误消息。
访问控制要求
要为预算调用此方法,需要具备以下权限和角色:
- ADMIN instance role for the budget instance.
- 对包含预算实例的数据库和架构的 USAGE 权限。
- 对包含存储过程的数据库和架构的 USAGE 权限。
- 对存储过程的 USAGE 权限。
For more information, see Budgets roles and privileges.
使用说明
-
Calling this method does not return the object. Because of this, you can’t use method chaining to call another method on the return value of this method. Instead, call each method in a separate SQL statement.
示例
Associate the alert_team stored procedure with the budget_db.sch1.my_budget budget so that it is
called when spending is forecast to reach 75% of the budget limit:
Associate the alert_team stored procedure with the budget_db.sch1.my_budget budget so that it is called when
spending has reached 90% of the budget limit: