Skip to content
Snippets Groups Projects
Commit c65940b9 authored by Christopher Lenke's avatar Christopher Lenke
Browse files

Neue Datei hochladen

parent ae02a4e6
No related branches found
No related tags found
No related merge requests found
-- DROP FUNCTION schema_xyz.is_hi_in_date_pg(int8, date, date);
CREATE OR REPLACE FUNCTION schema_xyz.is_hi_in_date_pg(my_uid bigint, my_first_date date, my_last_date date)
RETURNS bigint
LANGUAGE plpgsql
AS $function$
DECLARE
ergebnis bigint;
BEGIN
select count(*) into ergebnis
from schema_xyz.relation where uid_1=my_uid and uid_0=0
and type in (0,1)
--and ((extract(year from first_date) <= my_first_year and extract(year from last_date) > my_first_year)
--or (extract(year from first_date) < my_last_year and extract(year from last_date) >= my_last_year));
and ((first_date >= my_first_date and first_date <= my_last_date)
or (last_date >= my_first_date and last_date <= my_last_date)
or (first_date <= my_first_date and last_date >= my_last_date)
);
/*
if my_first_year=my_last_year then
select count(*) into ergebnis
from relation where uid_1=my_uid and uid_0=0
and type in (0,1)
and ((extract(year from first_date) = my_first_year and extract(year from last_date) = my_last_year));
end if;
*/
if ergebnis >0 then ergebnis:=1;
else ergebnis:=0;
end if;
RETURN ergebnis;
end;
$function$
;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment