Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Adding single quote to Snowflake variable in Javascript Stored Procedure

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.

var DEFAULT_STR = 'UNKNOWN'

var VAL_LIST = 'EMP_ID'

VAL_LIST = VAL_LIST +" "+ "'`${DEFAULT_STR}`'" + ','+ '"SYSTEM"';

Error Message:

SQL compilation error: error line 1 at position 183 invalid identifier '"${DEFAULT_STR}"' At Snowflake.execute

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Please advise how I can achieve below expected output-

Expected output:

'EMP_ID UNKNOWN, SYSTEM"

>Solution :

This one should give you the output you want:

VAL_LIST = "'" + VAL_LIST +" "+ DEFAULT_STR + "," + "SYSTEM'";

The output of VAL_LIST is:

'EMP_ID UNKNOWN,SYSTEM'
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading