I am trying to add single quote around the string and assign it to variable in a Snowflake Stored Procedure. But the value is returning as DEFAULT_STR as is. Error Message: SQL compilation error: error line 1 at position 183 invalid identifier ‘”${DEFAULT_STR}”‘ At Snowflake.execute Please advise how I can achieve below expected output- Expected output: ‘EMP_ID UNKNOWN, SYSTEM” Answer
Tag: snowflake-cloud-data-platform
How to pass input from user to a java script function inside a snowflake UDF?
I have to convert some JS functions to snowflake udfs. It works successfully with hardcoded sample data but I can’t make it accept user input as arguments. I know the UDF’s create statement is supposed to take the input but I cannot make it work. Thanks for the help. Answer Assuming that arguments to provide are inside map.set(“SKU”,”Common Measurement (L
Snowflake/javascript datetime format changes during iteration
Javascript converts above date into something like this ‘Tue Dec 07 2021 14:52:12 GMT-0800 (Pacific Standard Time)’ Here is the javascript code Above code between ** … ** is modifying the timestamp however i need to get same datetime stamp(2021-12-07 15:17:04.673 -0800) and NOT ‘Tue Dec 07 2021 14:52:12 GMT-0800 (Pacific Standard Time)’ How to format the javascript iteration code
Snowflake sp Javascript
While trying to execute the proc as below I am getting this error JavaScript compilation error: Uncaught SyntaxError: missing ) after argument list in TEST_09171 at ‘ IF(C_MKTSEGMENT is null)’ position 7 Answer You have a greater than symbol here that you need to remove: This line is supposed to be JavaScript but it’s written as SQL: It should be
snowflake string replace javascript udf
Trying to utilize Javascript’s String.prototype.replace() function in Snowflake, because apparently Snowflake’s regex_replace function lacks certain features such ast (forward/backward) look arounds. Here is my Javascript UDF attempt: However, when I try to execute using the example provided in the string.prototype.replace() documentation linked above. I’m not getting the expected result: Any ideas? Answer because in Javascript the regex is not string
Inserting parameters of stored procedure into a table using Merge in snowflake
I am trying to insert the parameter values of a stored procedure into the table using merge function in sql. The parameters consists of DB and schema name. I have written a stored procedure for that but, I don’t understand where I’m doing wrong. Here is my attempt: Answer You can use binds: See https://docs.snowflake.com/en/sql-reference/stored-procedures-usage.html#binding-variables for more info.