Insert results from js function to snowflake table

  Kiến thức lập trình

I have a js function, which prepares query, then execute it on snowflake and keep result of it in variable:

function objectGet(db, view, schema, object) {
        const x = `select get_ddl('${view}', '"${db}"."${schema}"."${object}"') as "result";`
        const res = snowflake.createStatement( { sqlText: x } ).execute();

if (res.next()) {
            return res.result
        }

Then I want to insert the result from previous function to the table, but it doesn’t work for me. How can I insert those results to table?

 function add() {
      let result = objectGet(x.db, x.view, x.schema, x.object);
            let insertt = `
            INSERT INTO "Base"."Schema"."Example"
            (col)
            VALUES
            ("${result}")`;
            snowflake.createStatement({ sqlText: insertt }).execute();

Insert results from js function to snowflake table

I have a js function, which prepares query, then execute it on snowflake and keep result of it in variable:

function objectGet(db, view, schema, object) {
        const x = `select get_ddl('${view}', '"${db}"."${schema}"."${object}"') as "result";`
        const res = snowflake.createStatement( { sqlText: x } ).execute();

if (res.next()) {
            return res.result
        }

Then I want to insert the result from previous function to the table, but it doesn’t work for me. How can I insert those results to table?

 function add() {
      let result = objectGet(x.db, x.view, x.schema, x.object);
            let insertt = `
            INSERT INTO "Base"."Schema"."Example"
            (col)
            VALUES
            ("${result}")`;
            snowflake.createStatement({ sqlText: insertt }).execute();

LEAVE A COMMENT