drop function if exists fw_core.fn_jobctl_block_end;
CREATE OR REPLACE FUNCTION fw_core.fn_jobctl_block_end(p_file_syspk int,p_block_table_name text)
   RETURNS void AS $$
begin

/********************************* 
select staging2.fn_jobctrl_block_end(255,'block1')
*********************************/

execute 'update fw_core.fw_jobctl_file_sheet_block_run_schedule set end_status=1 , end_time=now(), end_status_note=''completed''
where file_syspk='''||p_file_syspk||'''and block_table_name='''||p_block_table_name||'''';

end
$$ LANGUAGE plpgsql;
