VBUC
Visual Basic Upgrade Companion. VB6 Converter for .NET & Web.

VB6
ASP
.NET7 supportDownload Now

WebMAP
Cloud Application Migration Tools Transform Desktop Applications

C#
Silverlight
Access
VB.NET
PowerBuilder
Winforms
ASP.NET Web Forms

SnowConvert
The best available tools to perform code migrations from a source database or Spark application to Snowflake.

Oracle
Spark Scala
Spark Python
SQL Server
Teradata

Get Started
There are countless ways to take advantage of BlackDiamond Studio and SnowConvert.

Migration and Other Snowflake Services
Get Up and Running with Snowpark
Using the SnowConvert Trial
Build a Cross-Platform Object Inventory

Try BlackDiamond Studio

Time to Mobilize
Free Assessment Tool

How to use '$$' inside a Snowflake procedure

by Mauricio Rojas, on Apr 5, 2022 6:55:17 AM

This may be a small post, but hopefully, it will save you some time.

Recently, I had the problem where I had a procedure in Snowflake that was using the '$$' on a literal.

Lets say something like: INSERT INTO TABLE1(COL1) VALUES 'SOMEVALUE$$SOMEVALUE';

My stored procedure was something simple:

CREATE OR REPLACE PROCEDURE FOO() RETURNS STRING LANGUAGE JAVASCRIPT AS $$
snowflake.execute(sqlText:"INSERT INTO TABLE1(COL1) VALUES 'SOMEVALUE$$SOMEVALUE'");
$$

Everything should work, right? Tragically, this was the result:

SQL compilation error: syntax error line 3 at position 71 unexpected 'SOMEVALUE'. parse error line 5 at position 3 near '<EOF>'. parse error line 5 at position 3 near '<EOF>'.

The solution was simple. Just use an escape code like '\$' for example:

CREATE OR REPLACE PROCEDURE FOO() RETURNS STRING LANGUAGE JAVASCRIPT AS $$
snowflake.execute(sqlText:"INSERT INTO TABLE1(COL1) VALUES 'SOMEVALUE\$\$SOMEVALUE'");
$$

And now you won't get any errors.

Topics:Snowflake

Comments

Subscribe to Mobilize.Net Blog

More...

More...
FREE CODE ASSESSMENT TOOL