/**
 * @author Titouan
 * @date 25/05/21
 * @version 1.0.0
 * @project SIEau
 * @table public.codes_sandre
 */

# --- !Ups

create or replace function getTownName(code VARCHAR) returns varchar(200)
    language plpgsql
as $$
DECLARE
    c_libelle varchar(200);;
BEGIN
    select (coalesce(nom, '') || ' [' || codecommune || ']') into c_libelle from communes where codecommune = code;;
    return c_libelle;;
END
$$;

# --- !Downs