
create or replace function show(type smallint, id bigint) returns text as $$
declare tname text := (select dtname from datatypes as dt where dt.id = type);
begin
    case tname
        when 'node' then
            return (
                select ns.prefix || ':' || n.name 
                    from nodes n
                    join namespaces ns on ns.id = n.namespace
                    where n.id = show.id
            );
        else return tname;
    end case;
end;
$$ language plpgsql;
