Netezza 存储过程

来源:互联网 发布:cmd打开端口命令 编辑:程序博客网 时间:2024/05/21 17:29
CREATE OR REPLACE PROCEDURE sp_sas_process_trigger(national character varying(any), national character varying(any), bigint)RETURNS character varying(ANY)LANGUAGE NZPLSQL ASBEGIN_PROCDECLAREP_country ALIAS FOR $1;P_sitesegment ALIAS FOR $2;P_timespan ALIAS FOR $3;v_sql nvarchar(3000);BEGINv_sql := 'call sp_drop_if_exists(''temp_test_'||P_country||'_'||P_sitesegment||'_'||P_timespan||''') ;' ;execute immediate v_sql ;v_sql := ' create table temp_test_'||P_country||'_'||P_sitesegment||'_'||P_timespan||' as select a.dim_plat_site_id, a.country_2char, b.final_segment_name, now() as create_dt from dim_plat_site_camp   a join vw_curr_site_segment_apj  bon  a.dim_plat_site_id=b.dim_plat_site_id  join snapshot_plat_site  c  on a.dim_plat_site_id=c.dim_plat_site_idwhere a.country_2char='||quote_literal(upper(P_country))||' and upper(b.final_segment_name)=upper(case when '||quote_literal(P_sitesegment)||' like ''%plus%'' then ''SB+'' else '||quote_literal(P_sitesegment)||' end)  and b.bispy_segment_name in (''Buyer'', ''Payer(Y)'') and b.lcm_segment_name in (''New Welcome'', ''Develop and Retain'')and c.first_order_dt between now()-'||P_timespan||' and now()' ;raise notice 'V_sql is :%', v_sql;execute immediate v_sql ;return 'Done' ;END;END_PROC;

0 0