create or replace function reports (report_id integer, adviser_id integer,provider_id integer, introducer_id integer, plangroup_id integer, plantype_id integer, datespecific_start date, datespecific_end date,child24 date,child26 date) returns record as' declare myrec record; begin --PandC report if report_id=18 then select into myrec tblemployee.employee_first_name,tblemployee.employee_surname,tblnewbusiness.newbusiness_date_issued, tblclient.client_first_name,tblclient.client_middle_names,tblclient.client_surname,tblplantypes.plantype_group, tblplangroups.plan_group,tblproviders.provider_company, tblnewbusiness.newbusiness_policy_number, tblnewbusiness_sum_assured,tblnewbusiness.newbusiness_benefit, tblnewbusiness.newbusiness_premium, tblnewbusiness.brokerage,tblnewbusiness.newbusiness_comments from tblproviders right join tblnewbusiness on (tblproviders.provider_ref=tblnewbusiness.provider_ref); return myrec; --task by provider else if report_id=23 then --exceptions else if report_id=25 then --lead actions required else if report_id=13 then end if; end if; end if; end if; return myrec; end; ' language 'plpgsql';