forked from hernan-alperin/Segmentacion-CORE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathno_propagar.sql
51 lines (43 loc) · 1.07 KB
/
no_propagar.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
titulo: no_propagar.sql
descripción:
funciones que devuelven
las mnzas o lados que no
se pueden propagar de lados completos a tabla segmentacion
por tener cantidad excedida
autor: -h
fecha: 2020-10
*/
create or replace function indec.lados_excedidos(esquema text, umbral integer)
returns table (
prov integer, dpto integer, codloc integer, frac integer, radio integer, mza integer, lado integer
)
language plpgsql volatile
set client_min_messages = error
as $function$
begin
return query
execute '
select prov, dpto, codloc, frac, radio, mza, lado
from "' || esquema || '".v_segmentos_lados_completos
where vivs > ' || umbral || '
;';
end;
$function$
;
create or replace function indec.mzas_con_lado_excedido(esquema text, umbral integer)
returns table (
prov integer, dpto integer, codloc integer, frac integer, radio integer, mza integer, lado integer
)
language plpgsql volatile
set client_min_messages = error
as $function$
begin
return query
execute '
select distinct prov, dpto, codloc, frac, radio, mza
from indec.lados_excedidos(esquema, umbral)
;';
end;
$function$
;