Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda