101 lines
3.7 KiB
PL/PgSQL
Executable File
101 lines
3.7 KiB
PL/PgSQL
Executable File
|
|
|
|
|
|
CREATE OR REPLACE FUNCTION fw_core.fn_update_NA(filesyspk integer)
|
|
RETURNS void
|
|
LANGUAGE plpgsql
|
|
AS $function$
|
|
/***********
|
|
select fw_core.fn_update_NA()
|
|
********/
|
|
declare
|
|
__n integer:=0;
|
|
__na_sql text;
|
|
__space_sql text;
|
|
__div_sql text;
|
|
__ref_sql text;
|
|
__hyphen_sql text;
|
|
__hyphen_3_sql text;
|
|
__not_applicable text;
|
|
__NR text;
|
|
__Dots_1 text;
|
|
__Dots_2 text;
|
|
__trail_trim_columns text;
|
|
__lead_trim_columns text;
|
|
__Dots_3 text;
|
|
__inverted_comma text;
|
|
__underscore text;
|
|
__hashvalue text;
|
|
begin
|
|
loop
|
|
exit when __n=53;
|
|
__n := __n+1;
|
|
|
|
__na_sql := 'update staging1.staging_generic_table set '|| concat('column',__n)||' =null
|
|
where '||concat('column',__n)||'=''NA'' and file_syspk=' ||filesyspk;
|
|
|
|
__space_sql := 'update staging1.staging_generic_table set '|| concat('column',__n)||' =null
|
|
where '||concat('column',__n)||'='''' and file_syspk=' ||filesyspk;
|
|
|
|
__div_sql := 'update staging1.staging_generic_table set '|| concat('column',__n)||' =null
|
|
where '||concat('column',__n)||'=''#REF!'' and file_syspk=' ||filesyspk;
|
|
|
|
__ref_sql := 'update staging1.staging_generic_table set '|| concat('column',__n)||' =null
|
|
where '||concat('column',__n)||'=''#DIV/0!'' and file_syspk=' ||filesyspk;
|
|
|
|
__hyphen_sql := 'update staging1.staging_generic_table set '|| concat('column',__n)||' =null
|
|
where '||concat('column',__n)||'=''-'' and file_syspk=' ||filesyspk;
|
|
|
|
__hyphen_3_sql := 'update staging1.staging_generic_table set '|| concat('column',__n)||' =null
|
|
where '||concat('column',__n)||'=''---'' and file_syspk=' ||filesyspk;
|
|
|
|
__not_applicable := 'update staging1.staging_generic_table set '|| concat('column',__n)||' =null
|
|
where '||concat('column',__n)||'=''Not Applicable '' and file_syspk=' ||filesyspk;
|
|
|
|
__NR := 'update staging1.staging_generic_table set '|| concat('column',__n)||' =null
|
|
where '||concat('column',__n)||'=''NR'' and file_syspk=' ||filesyspk;
|
|
|
|
__Dots_1 := 'update staging1.staging_generic_table set '|| concat('column',__n)||' =null
|
|
where '||concat('column',__n)||'=''u..'' and file_syspk=' ||filesyspk;
|
|
|
|
__Dots_2 := 'update staging1.staging_generic_table set '|| concat('column',__n)||' =null
|
|
where '||concat('column',__n)||'=''u.'' and file_syspk=' ||filesyspk;
|
|
|
|
__Dots_3 := 'update staging1.staging_generic_table set '|| concat('column',__n)||' =null
|
|
where '||concat('column',__n)||'=''.'' and file_syspk=' ||filesyspk;
|
|
|
|
__inverted_comma := 'update staging1.staging_generic_table set '|| concat('column',__n)||' =null
|
|
where '||concat('column',__n)||'=''`'' and file_syspk=' ||filesyspk;
|
|
|
|
__trail_trim_columns:='update staging1.staging_generic_table set '|| concat('column',__n)||' = trim(trailing from '|| concat('column',__n)||')
|
|
where file_syspk=' ||filesyspk;
|
|
|
|
__lead_trim_columns:='update staging1.staging_generic_table set '|| concat('column',__n)||' = trim(leading from '|| concat('column',__n)||')
|
|
where file_syspk=' ||filesyspk;
|
|
|
|
__underscore := 'update staging1.staging_generic_table set '|| concat('column',__n)||' =null
|
|
where '||concat('column',__n)||'=''_'' and file_syspk=' ||filesyspk;
|
|
|
|
__hashvalue := 'update staging1.staging_generic_table set '|| concat('column',__n)||' =null
|
|
where '||concat('column',__n)||'=''#VALUE!'' and file_syspk=' ||filesyspk;
|
|
|
|
|
|
execute __na_sql;
|
|
execute __space_sql;
|
|
execute __div_sql;
|
|
execute __ref_sql;
|
|
execute __hyphen_sql;
|
|
execute __hyphen_3_sql;
|
|
execute __not_applicable;
|
|
execute __NR;
|
|
execute __Dots_1;
|
|
execute __Dots_2;
|
|
execute __Dots_3;
|
|
execute __trail_trim_columns;
|
|
execute __lead_trim_columns;
|
|
execute __underscore;
|
|
execute __hashvalue;
|
|
execute __space_sql;
|
|
end loop;
|
|
end;
|
|
$function$ |