I am trying to use Snowflake stored procedures and would like to print the SQL statement in the stored procedure below to the screen.
CREATE OR REPLACE PROCEDURE read_western_provinces()
RETURNS VARCHAR NOT NULL
LANGUAGE JAVASCRIPT
AS
$$
var return_value = "";
try {
var command = "SELECT * FROM western_provinces ORDER BY province;"
var stmt = snowflake.createStatement( {sqlText: command } );
var rs = stmt.execute();
if (rs.next()) {
return_value += rs.getColumnValue(1);
return_value += ", " + rs.getColumnValue(2);
}
while (rs.next()) {
return_value += "\n";
return_value += rs.getColumnValue(1);
return_value += ", " + rs.getColumnValue(2);
}
}
catch (err) {
result = "Failed: Code: " + err.code + "\n State: " + err.state;
result += "\n Message: " + err.message;
result += "\nStack Trace:\n" + err.stackTraceTxt;
}
return return_value;
$$
;
How can I print the value of command variable (which contains the SQL) to the screen whenever stored procedure is executed?
thanks