Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

42
Vistas
Snowflake sp Javascript
create or replace procedure test_09171(c_custkey varchar(25)
 , c_mktsegment varchar(25)
 , cname varchar(25)) returns string not null   language javascript   execute as owner   as   $$
  var sqlquery="";>         
   var VMAJOR="";
   var VMINOR="";
          try   {
 IF (C_MKTSEGMENT IS NULL OR CNAME IS NULL OR C_MKTSEGMENT =' ' OR CNAME =' ')
  {
  var sql_command  =`SELECT C_MKTSEGMENT,cname
                    from customers                  
                    WHERE ccustkey=C_CUSTKEY`;
 var rs=snowflake.createStatement( {sqlText: sql_command});
 var result_set1 = rs.execute();
 while(result_set1.next()){
 VMAJOR =result_set1.getColumnValue(1);
 return C_MKTSEGMENT;
 VMINOR =result_set1.getColumnValue(1);
 return CNAME;
 }
  }  return "succeeded" } 
 catch(error)
 {
 return error.message
 }   $$;

While trying to execute the proc as below

call test_09171('1369097','','Customer#001369097');

I am getting this error

JavaScript compilation error: Uncaught SyntaxError: missing ) after argument list in TEST_09171 at ' IF(C_MKTSEGMENT is null)' position 7

7 months ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

you may give it a try with CALLED ON NULL INPUT

More details: https://docs.snowflake.com/en/sql-reference/sql/create-procedure.html#optional-parameters

7 months ago · Juan Pablo Isaza Denunciar

0

You have a greater than symbol here that you need to remove:

var sqlquery="";> 

This line is supposed to be JavaScript but it's written as SQL:

IF (C_MKTSEGMENT IS NULL OR CNAME IS NULL OR C_MKTSEGMENT =' ' OR CNAME =' ')

It should be in JavaScript:

if (C_MKTSEGMENT == null || CNAME == null || C_MKTSEGMENT == ' ' || CNAME == ' ')
7 months ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos