0
votes

I am new to snowflake so please bear with me. I am trying to do a very simple thing - specify a column name by literal but am getting sql compilation error insert into MYDB.MYSCHEMA.MYTABLE (identifier('MYCOLUMN')) values (10);

SQL compiler points into unexpected parenthesis before MYCOLUMN. Skipping the word identifier and single qotes works fine.

2
So if you are going to use a stored procedure to build dynamic SQL, just inject the column name via stored procedure. It doesn't really make sense to "master using session variables", if you that is not what your are trying to has as an end goal.Simeon Pilgrim

2 Answers

1
votes
create table mytable(MYCOLUMN number);
insert into MYTABLE (MYCOLUMN) values (10); 

Works just fine for me.

Now if you want your column to be all fancy case instead of being case insensitive and being auto upper cased, you can wrap the name in double quotes "AwSoMeName WITH spaces" is valid, but also really pain.

create table MY_TABLE_2("AwSoMeTable WITH spaces" number);
insert into MY_TABLE_2 ("AwSoMeTable WITH spaces") values (10); 
1
votes

Just got a response from Snowflake support. Currently "identifier" is only supported for select statements. It is not implemented for inserts for identifying columns. It does work for identifying tables n both select and insert.