- Categories:
System functions (System Control)
SYSTEM$SET_ REFERENCE¶
Called by a Snowflake Native App to associate a consumer reference string to a reference definition. The app can use this association to access the consumer object. The reference string passed to this system function is the value returned by the SYSTEM$REFERENCE function, which represents a consumer object.
This function only supports a single-valued reference. If an association has already been created using the same reference name, the existing association is overwritten.
Syntax¶
Arguments¶
Required
'reference_name'The name of the reference as specified in the
manifest.ymlfile of the app.'reference_string'The system-generated ID of the reference to the object in the consumer account.
Returns¶
Returns a VARCHAR value that contains the system-generated alias for the association.
Examples¶
This example assumes that the app manifest defines a single-valued consumer_table reference
with object type TABLE and the SELECT privilege. The app’s setup script must also create
the config schema and app_admin application role and grant USAGE on the schema to that role.
For the manifest and setup-script prerequisites, see Request references and object-level privileges from consumers.
Add this procedure to the app’s setup script:
After installing the app as my_app, a consumer whose role can create the reference and has
the my_app.app_admin application role can associate an existing table with consumer_table:
The procedure returns a UUID alias, for example:
To replace the association with a different existing table, create a reference to that table and call the procedure again:
The second call replaces the existing association and returns a new system-generated alias. The UUID shown here is illustrative, not a fixed return value.