create or replace function rpt1.han_evnps_evensection_pg(p_evnps_id bigint) returns table (
  lpusection_name character varying,
  es_date text,
  lpusectionward_name text)
language plpgsql as $plpgsql$
	BEGIN
	return query
	select 
		ls.lpusection_name::varchar, 
		to_char(es.evnsection_setdate, 'dd.mm.yyyy'):: text || ' '|| to_char(es.evnsection_settime, 'HH24:MI')::text es_date ,
		lsw.lpusectionward_name::text
from v_evnps eps
inner join v_evnsection es on es.evnsection_pid=eps.evnps_id
left join v_LpuSection as ls on ls.LpuSection_id = es.LpuSection_id
left join v_LpuSectionWard as LSW 
		on LSW.LpuSectionWard_id = es.LpuSectionWard_id
where evnps_id= p_evnps_id
	;
END$plpgsql$;

