refactoring: replace procedure find_citizen_by_* to function and include user into citizen object

This commit is contained in:
2019-07-26 16:29:11 +02:00
parent 8581ebb558
commit 2286568ae9
3 changed files with 24 additions and 14 deletions

View File

@@ -1,12 +1,17 @@
create or replace procedure find_citizen_by_id(in id uuid, inout resource json) language plpgsql as
create or replace function find_citizen_by_id(in id uuid, out resource json) language plpgsql as
$$
declare
_id alias for id;
begin
select to_json(z) into resource
from citizen as z
where z.id = _id;
select to_json(t) into resource
from (
select
z.*,
find_user_by_id(z.user_id)
from citizen as z
where z.id = _id
) as t;
end;
$$;
-- drop procedure if exists find_citizen_by_id(uuid, inout json);
-- drop function if exists find_citizen_by_id(uuid, inout json);