Thankyou for your time.
I am working on a problem in Snowflake database. I am basically trying to create a Javascript UDF like following -
CREATE OR REPLACE FUNCTION getACity()
RETURNS STRING
LANGUAGE JAVASCRIPT
AS
'function getCity() {
var str;
$$ str = select * from CITY where name="Laflin" //This is the problem
$$
return str;
}';
As you can see I am trying to use data from another table in my function, but its not happening and I get following error -
JavaScript compilation error: Uncaught SyntaxError: Unexpected identifier in getACity at ' str = select * from CITY where name="Laflin"' position 21
I understand the syntax I am using to execute a query inside a javascript function is not correct, but I am not even sure if it is possible in Snowflake.
I have following questions -
- Can I execute a query inside a javascript UDF and use the results in ongoing function ?
- Can I call a Javascript UDF inside another Javascript UDF ? If this is possible it will work for me as well.
I have gone through Snowflake documentation but could not find any help specific to this case.
Thankyou again for your time. Much appreciated !