I have a many (snowflake) javascript stored procedures per data pipeline , in all the procedures I have this function defined.
create or replace procedure procedure1()
returns strint
language javascript
as
'
function returnResult(sql_text){
rs = snowflake.execute({sqlText:sql_text});
rs.next();
return rs.getColumnValue(1);
}
--declare constants
--declare variables
--perform some checks
return returnResult(`call procedure2('param1', 'param2')`);
'
;
I use this to execute sql's multiple times inside the same procedure .like
return returnResult(`call procedure2('param1', 'param2')`);
Note: I don't want to use the function call in 'select statement'
Is there a way I store this function 'returnResult' globally once and use in all the stored procedures ?
Along with this, Can I define any variable globally and use in multiple stored procedures (pipelines) ?
I tried creating UDF's but it does not look to be the right approach.