Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

243
Views
Procedimiento almacenado para insertar valores en una tabla de etapas desde otra tabla en copo de nieve

Aquí está el proceso almacenado que creé. Pero cuando trato de llamarlo, aparece un error de línea de análisis.


 Create or replace procedure insert_into_staged1() RETURNS STRING NOT NULL LANGUAGE JAVASCRIPT AS $$ var sql_cmd = `Insert into staging_table(select xyz as xyz, abc as old_abc, case when rx_code in ('1234','5432') and trim(split_part(upper(abc),'*',1)) in ('GOOGLE','APPLE','SAMSUNG') then trim(split_part(upper(abc),'*',1)) when rx_code in ('6012') and trim(split_part(upper(abc),'*',1)) else coalesce(replace(abc,'\"','\''),'') end as abc_new from table2)` var sql = snowflake.createStatement({sqlText: sql_cmd}); var result = sql.execute(); return 'success'; $$;
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Prueba esto:

 Create or replace procedure insert_into_staged1() RETURNS STRING NOT NULL LANGUAGE JAVASCRIPT AS $$ var sql_cmd = ` Insert into staging_table select xyz as xyz, abc as old_abc, case when rx_code in ('1234','5432') and trim(split_part(upper(abc),'*',1)) in ('GOOGLE','APPLE','SAMSUNG') then trim(split_part(upper(abc),'*',1)) when rx_code in ('6012') and trim(split_part(upper(abc),'*',1)) then coalesce(replace(abc,'\"','\'''),'') end as abc_new from table2`; var sql = snowflake.createStatement({sqlText: sql_cmd}); var result = sql.execute(); return 'success'; $$;
about 4 years ago · Juan Pablo Isaza Report

0

Intenté ejecutar su instrucción SQL y descubrí que faltaba THEN en uno de los casos.

 The corrected function added. --ORiginal select xyz as xyz, abc as old_abc, case when rx_code in ('1234','5432') and trim(split_part(upper(abc),'*',1)) in ('GOOGLE','APPLE','SAMSUNG') then trim(split_part(upper(abc),'*',1)) when rx_code in ('6012') and trim(split_part(upper(abc),'*',1)) else coalesce(replace(abc,'\"','\''),'') end as abc_new from table2 --Corrected select xyz as xyz, abc as old_abc, case when rx_code in ('1234','5432') and trim(split_part(upper(abc),'*',1)) in ('GOOGLE','APPLE','SAMSUNG') then trim(split_part(upper(abc),'*',1)) when rx_code in ('6012') and trim(split_part(upper(abc),'*',1)) then 'Correction added' else coalesce(replace(abc,'\"','\''),'') end as abc_new from table2; create table staging_table AS select xyz as xyz, abc as old_abc ,case when rx_code in ('1234','5432') and trim(split_part(upper(abc),'*',1)) in ('GOOGLE','APPLE','SAMSUNG') then trim(split_part(upper(abc),'*',1)) when rx_code in ('6012') and trim(split_part(upper(abc),'*',1)) then 'missing then' else coalesce(replace(abc,'\"','\''),'') end as abc_new from table2; create or replace table table2 (rx_code varchar2(100), split_part varchar2(100), xyz varchar2(120), abc varchar2(100)); select column1, case when column1=1 then 'one' when column1=2 then 'two' else 'other' end as result from (values(1),(2),(3)) v; Create or replace procedure insert_into_staged1() RETURNS STRING NOT NULL LANGUAGE JAVASCRIPT AS $$ var sql_cmd = `select xyz as xyz, abc as old_abc ,case when rx_code in ('1234','5432') and trim(split_part(upper(abc),'*',1)) in ('GOOGLE','APPLE','SAMSUNG') then trim(split_part(upper(abc),'*',1)) when rx_code in ('6012') and trim(split_part(upper(abc),'*',1)) then 'missing then' else coalesce(replace(abc,'\\"','\\''),'') end as abc_new from table2` var sql = snowflake.createStatement({sqlText: sql_cmd}); var result = sql.execute(); return 'success'; $$; call insert_into_staged1();
about 4 years 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 vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!