Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

41
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.