CREATE OR REPLACE PROCEDURE platform_common.tags.store_tags()
RETURNS STRING
LANGUAGE SQL
AS
$$
BEGIN
-- Create or replace the table to store the tags
CREATE OR REPLACE TABLE platform_common.tags (
database_name STRING,
schema_name STRING,
tag_name STRING,
comment STRING,
allowed_values STRING,
propagate STRING
);
-- Execute the SHOW TAGS command and store the result
EXECUTE IMMEDIATE 'SHOW TAGS IN ACCOUNT';
-- Insert the results into the tags table
INSERT INTO platform_common.tags (database_name, schema_name, tag_name, comment, allowed_values, SELECT
"database_name",
"schema_name",
"name" AS "tag_name",
"comment",
"allowed_values",
"propagate"
FROM
TABLE(RESULT_SCAN(LAST_QUERY_ID()))
WHERE
"database_name" != 'SNOWFLAKE'
ORDER BY
"created_on";
RETURN 'Tags stored successfully in platform_common.tags';
END;
$$;