create or replace function fn_getGtipNoktali(p_gtip varchar) returns varchar language plpgsql as $$ declare temp_gtip varchar; ret_gtip varchar; begin SELECT replace(p_gtip, '.', '') into temp_gtip; select SUBSTRING ( temp_gtip ,0 , 5 )||'.'||SUBSTRING ( temp_gtip ,5 , 2 )||'.'||SUBSTRING ( temp_gtip ,7 , 2 )||'.'||SUBSTRING ( temp_gtip ,9 , 2 )||'.'||SUBSTRING ( temp_gtip ,11 , 2 ) into ret_gtip; return ret_gtip; end;$$