Reputation: 35
I am struggling to get this code to work, not sure how to do it in PL/SQL like T-SQL, ive tried both:
-- input the Application name
SET CustomRoleName = 'FakeApplicationName';
-- create the base custom roles
create role identifier($CustomRoleName) comment = 'This is ' || $CustomRoleName || ' read-only role';
but get error:
Syntax error: unexpected '||. (line 14)
and
-- input the Application name
SET CustomRoleName = 'FakeApplicationName';
-- create the base custom roles
create role identifier($CustomRoleName) comment = 'This is ' + $CustomRoleName + ' read-only role';
but get error:
Syntax error: unexpected '+'. (line 14)
Cant find anything on the internet about concatenating a variable in Snowflake for a varchar column
Upvotes: 2
Views: 2039
Reputation: 176124
Using Snowflake Scripting:
DECLARE
CustomRoleName STRING DEFAULT 'FakeApplicationName';
QUERY STRING;
BEGIN
QUERY:= REPLACE(
'create role <role_name> comment = ''This is <role_name> read-only role'';'
,'<role_name>', :CustomRoleName);
EXECUTE IMMEDIATE :QUERY;
RETURN :QUERY;
END;
Output(classic UI):
Upvotes: 1