create or replace function fn_getIsemriDurum(p_durum_id int) returns varchar language plpgsql as $$ declare ret_aciklama varchar; begin select aciklama into ret_aciklama from durumlar where id = p_durum_id; if not found then raise 'Durum id % not found', p_durum_id; end if; return ret_aciklama; end;$$