<budget_name>!ADD_TAG¶
Adds a tag to a custom budget. The tag must be added by reference.
Syntax¶
<budget_name>!ADD_TAG(
{ '<tag_reference>' | <reference_statement> },
'<tag_value>')
Arguments¶
'tag_reference'
The serialized string representation that resolves to a tag. This string is the output of the SYSTEM$REFERENCE function.
reference_statement
A SYSTEM$REFERENCE statement that creates a reference for the tag to be added to the budget.
'tag_value'
The value of the tag you are adding to the budget.
Returns¶
Returns a VARCHAR value that indicates whether or not the tag was successfully added to the budget.
If the tag could not be added to the budget, the function returns an error message.
Access control requirements¶
The following privileges and roles are required to call this method for a custom budget:
ADMIN instance role for the budget instance.
USAGE privilege on the database and schema that contain the budget instance.
USAGE privilege on the database and schema that contain the tag.
APPLYBUDGET privilege on the tag being added.
For more information, see Budgets roles and privileges.
Usage notes¶
You can only add tags to custom budgets.
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.
Examples¶
- Retrieve the tag reference before calling the method to add a tag.
The following statement creates and returns a reference for the
cost_center
tag:SELECT SYSTEM$REFERENCE( 'TAG', 'cost_mgmt_db.tags.cost_center', 'SESSION', 'APPLYBUDGET');
The statement returns the reference in the output.
ENT_REF_TAG_10382726315710_8A8626AE765E29446C38A217CAD093FCC9A454C2
The following statement uses the string literal for this reference to add the
cost_center = 'sales'
tag/value combination to thebudget_db.budget_schema.my_budget
budget:CALL budget_db.budget_schema.my_budget!ADD_TAG( 'ENT_REF_TAG_10382726315710_8A8626AE765E29446C38A217CAD093FCC9A454C2', 'sales');
- Include the SYSTEM$REFERENCE function in the argument directly
After executing the following statement, the budget will track all objects that are tagged with the tag/value combination
team_tag = 'finance'
.CALL budget_db.budget_schema.my_budget!ADD_TAG( (SELECT SYSTEM$REFERENCE('TAG', 'cost_mgmt_db.tags.team_tag', 'SESSION', 'APPLYBUDGET')), 'finance');