create or replace function is_complete_cause_data (acct_year in varchar2,comp_code in varchar2,copy_code in varchar2,cause_code in varchar2, type_code int)
return  varchar2 asbegindeclare result varchar2if type_code :=1
begin
if exists(select 1 from HTCP_WORK_CAUSE_DATA where ACCT_YEAR=acct_year and COMP_CODE=comp_code
and COPY_CODE=copy_code and WORK_CAUSE_CODE=cause_code)
begin
 set result='已完成'
end;
else begin
set result='未完成'
end;
end;
else
begin
if exists(select 1 from HTCP_RES_CAUSE_DATA where HTC_ACCT_YEAR=acct_year and HTC_COMP_CODE=comp_code
and HTC_COPY_CODE=copy_code  and RES_CAUSE_CODE=cause_code)
begin
 set result='已完成'
end;
else begin
set result='未完成'
end;
end;return resultend;