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

Function: ps_creation_index_data_stat

 

 

Schema

safran

 

Owner

postgres

 

Descriptions

There is no description for function ps_creation_index_data_stat

 

Options

Option

Value

Returns

integer

Language

plpgsql

Parameters

There are no parameters for function ps_creation_index_data_stat

 

Definition

CREATE OR REPLACE FUNCTION safran.ps_creation_index_data_stat (
)
RETURNS integer AS
$span$
DECLARE

r1 record;
schema text DEFAULT 'safran';
idx1 text;
idx2 text;
idx3 text;

BEGIN
FOR r1 IN
SELECT DISTINCT
casind_nom_table
FROM t_carte_statistique_indicateur_casind
LOOP
idx1 := r1.casind_nom_table||'_idx_defmoy_cartid';
idx2 := r1.casind_nom_table||'_idx_debmed_cartid';
idx3 := r1.casind_nom_table||'_idx_durmoy_cartid';

IF NOT EXISTS (
SELECT 1
   FROM   pg_class c
   JOIN   pg_namespace n ON n.oid = c.relnamespace
   WHERE  c.relname = idx1
   AND    n.nspname = schema
) THEN
EXECUTE
'CREATE INDEX '|| idx1 ||' ON '|| schema ||'.'|| r1.casind_nom_table ||' USING btree (defmoy_cartid);';
END IF;

IF NOT EXISTS (
SELECT 1
   FROM   pg_class c
   JOIN   pg_namespace n ON n.oid = c.relnamespace
   WHERE  c.relname = idx2
   AND    n.nspname = schema
) THEN
EXECUTE
'CREATE INDEX '|| idx2 ||' ON '|| schema ||'.'|| r1.casind_nom_table ||' USING btree (debmed_cartid);';
END IF;

IF NOT EXISTS (
SELECT 1
   FROM   pg_class c
   JOIN   pg_namespace n ON n.oid = c.relnamespace
   WHERE  c.relname = idx3
   AND    n.nspname = schema
) THEN
EXECUTE
'CREATE INDEX '|| idx3 ||' ON '|| schema ||'.'|| r1.casind_nom_table ||' USING btree (durmoy_cartid);';
END IF;

END LOOP;

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