refactoring: move sql files

This commit is contained in:
2019-07-29 16:46:17 +02:00
parent 7408f8440b
commit 6560e400f3
27 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
create or replace function find_constitution_title_by_id(in id uuid, out resource json) language plpgsql as
$$
declare
_id alias for id;
begin
select to_json(t)
from (
select
ti.id,
ti.name,
ti.rank,
array_agg(a order by ait.rank) as articles
into resource
from title as ti
left join article_in_title ait on ti.id = ait.title_id
left join article a on ait.article_id = a.id
where ti.id = _id
group by ti.id
order by ti.rank
) as t;
end;
$$;
-- drop function if exists find_constitution_title_by_id(uuid, out json);