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

249
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 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