Monday 15 March 2010

sql - Control reached end of function without RETURN -



sql - Control reached end of function without RETURN -

i have function in postgresql , when i'm trying execute it, error message:

error: command reached end of function without homecoming context: pl/pgsql function "sa_prj".usp_add_timesheet_record_neww(integer,integer,numeric,numeric,character varying,character varying)

i'm not sure think homecoming problem, must have homecoming @ end ?

create or replace function "sa_prj".usp_add_timesheet_record_neww(p_uid integer, p_project_id integer, p_allocated_time numeric, p_achieved_time numeric, p_task_desc character varying, p_obs character varying) returns character varying $body$ declare alloc_id integer; declare project integer; declare allocated integer; declare allocated_time numeric; begin project := p_project_id; allocated_time := (select sum(fld_allocated_time) "sd_prj".tbl_project_timesheet fld_project_id = project); allocated := (select fld_allocated_days "sd_prj".tbl_project fld_id = project); if not "sa_adm".usp_check_permission(p_uid, 'sa_prj', 'usp_add_timesheet_record') raise exception 'user id % nu permisii pentru aceasta operatie!', p_uid; end if; select fld_id alloc_id "sd_prj".tbl_project_allocation fld_emp_id = p_uid , fld_project_id = p_project_id; begin if (allocated > allocated_time) insert "sd_prj".tbl_project_timesheet(fld_emp_id, fld_project_id, fld_is_allocated,fld_allocated_time, fld_achieved_time, fld_task_desc, fld_obs) values (p_uid,p_project_id,coalesce(alloc_id,0), p_allocated_time, p_achieved_time,p_task_desc, p_obs); raise notice 'ok'; else raise notice 'not ok!'; end if; end; end $body$ language plpgsql volatile cost 100;

thanks

either define function as:

create or replace function "sa_prj".usp_add_timesheet_record_neww(p_uid integer, p_project_id integer, p_allocated_time numeric, p_achieved_time numeric, p_task_desc character varying, p_obs character varying) returns void ...

or utilize return instead of raise notice (if thats want return)

sql postgresql stored-procedures postgresql-9.1

No comments:

Post a Comment