db_biljou_carto on db.silva.inrae.fr
Previous topic Chapter index Next topic

Function: ps_verificationdonneespresentes

 

 

Schema

safran

 

Owner

postgres

 

Descriptions

There is no description for function ps_verificationdonneespresentes

 

Options

Option

Value

Returns

integer

Language

plpgsql

Parameters

schema text

 

Definition

CREATE OR REPLACE FUNCTION safran.ps_verificationdonneespresentes (
 schema text
)
RETURNS integer AS
$span$
DECLARE

c record;
c1 record;
sql text;
exist boolean;
ids integer;
error integer DEFAULT 0;

BEGIN

FOR c IN
SELECT DISTINCT
caind_nom_table FROM public.t_carte_indicateur_caind
LOOP
sql := 'SELECT EXISTS (
  SELECT 1
  FROM   information_schema.tables
  WHERE  table_schema = '''
|| schema ||'''
  AND    table_name = '''
|| c.caind_nom_table ||'''
)'
;
EXECUTE sql INTO exist;

IF exist = 'f' THEN
error := error + 1;
RAISE NOTICE 'La table : % n''éxiste pas.', c.caind_nom_table;
FOR c1 IN
SELECT
caind_id, comb_libelle
FROM public.t_carte_indicateur_caind
INNER JOIN public.tr_combinaison_comb ON caind_comb_id = comb_id
WHERE caind_nom_table = c.caind_nom_table
LOOP
RAISE NOTICE 'ID des cartes concernées : %, libellé de la combinaison : %', c1.caind_id, c1.comb_libelle;
END LOOP;
END IF;
END LOOP;
IF error > 0 THEN
RAISE EXCEPTION
'Il existe des cartes dont les données ne sont pas présentes. Il manque % tables de données.', error;
END IF;

RETURN 0;
END;
$span$
LANGUAGE
'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
PARALLEL UNSAFE
COST
100;

This file was generated with SQL Manager for PostgreSQL (www.pgsqlmanager.com) at 07/12/2018 13:23
Previous topic Chapter index Next topic