You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

53 lines
1.8 KiB

return: text
lang: plpgsql
src: |
DECLARE
_cursor refcursor;
_sqlcmd text;
_todataprofile text;
_schema text;
result TEXT;
BEGIN
-- Suppression des profils inexistants
_sqlcmd = 'SELECT substr(nspname,17)
FROM pg_namespace
WHERE substr(nspname,1,16) = ''rh_data_profile_'' AND
LOWER(substr(nspname,17)) NOT IN (SELECT LOWER(t_data_profile.code) FROM rh.t_data_profile) '
;
OPEN _cursor FOR EXECUTE _sqlcmd;
FETCH _cursor INTO _todataprofile;
WHILE FOUND LOOP
BEGIN
RAISE NOTICE 'Suppression du data_profile %', _todataprofile;
EXECUTE 'SELECT base.cti_perform_hors_transaction(''SELECT rh.cti_gen_data_profile_views('''''||_todataprofile||''''')'')';
EXCEPTION
WHEN others THEN RAISE NOTICE 'Erreur %' , 'SELECT base.cti_perform_hors_transaction(''SELECT rh.cti_gen_data_profile_views('''''||_todataprofile||''''')'')';
END;
FETCH _cursor INTO _todataprofile;
END LOOP;
CLOSE _cursor;
-- Pour chaque data_profile défini, appeler rh.cti_gen_data_profile_views(_in_data_profile_code)
-- Lister les _in_data_profile_code
_sqlcmd = 'SELECT t_data_profile.code
FROM rh.t_data_profile
WHERE t_data_profile.code <> '''' '
;
OPEN _cursor FOR EXECUTE _sqlcmd;
FETCH _cursor INTO _todataprofile;
WHILE FOUND LOOP
BEGIN
RAISE NOTICE 'Traitement du data_profile %', _todataprofile;
EXECUTE 'SELECT base.cti_perform_hors_transaction(''SELECT rh.cti_gen_data_profile_views('''''||_todataprofile||''''')'')';
EXCEPTION
WHEN others THEN RAISE NOTICE 'Erreur %' , 'SELECT base.cti_perform_hors_transaction(''SELECT rh.cti_gen_data_profile_views('''''||_todataprofile||''''')'')';
END;
FETCH _cursor INTO _todataprofile;
END LOOP;
CLOSE _cursor;
return 'OK';
END;