3 0
Read Time:30 Second

Some times the requirement comes where we are supposed to load the CSV data. Moreover, this data is available at the Staging area and insert into the Snowflake table via the Javascript procedure.

However, We can use the below code to achieve the requirement.

CREATE OR REPLACE PROCEDURE TEST_COPY_SP()
RETURNS VARIANT
LANGUAGE JAVASCRIPT
EXECUTE AS CALLER
AS
$$
var return_rows = [];

var stmt = snowflake.createStatement({
sqlText: ‘COPY INTO my_table FROM @my_stage/my_file.csv’
});

var result = stmt.execute();
result.next();
return_rows.push(result.getColumnValue(1))

return return_rows;
$$

Procedure

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published. Required fields are marked *