Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
How to execute a SELECT query from Snowflake JAVASCRIPT UDF

I need to execute a select query from Snowflake UDF and assign to a variable.. Since am using variable i guess i can only use JAVASCRIPT UDF in snowflake like below..

But the select query inside Snowflake JAVASCRIPT UDF is returning NULL everytime...

Please advise..

create or replace function fun1()

returns float

language JAVASCRIPT

as

$$

var a

a=select * from emp where salary like '%100%' and empno=1

return a

$$
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Assuming below: You want to retrun salary of employee whose empno=1, you can write something like below:

create or replace procedure Fun1()
   returns  RETURNS TABLE (id int, name varchar) 
   language javascript
 
   as
   $$

 
 var sql_command = "select salary from emp where salary like '%100%' and empno=1'";
 var result;
    var stmt = snowflake.createStatement( {sqlText: sql_command} );
    var resultSet = stmt.execute();
    result=resultSet.next();
     return result;
  
$$;

If this is not the case, then you have to write TableUDf's to return the table data. You can use SQL Scripting as well.

Refer: https://docs.snowflake.com/en/developer-guide/snowflake-scripting/resultsets.html#label-snowscript-resultsets-use-return-table

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda