-=-=-=-=-=-=-=-=方法被调用-=-=-=-=-=-=-=-=-=
function JudgeExist(p_budgetid in varchar2) return number is
v_count number(2);
begin
select count(1)
into v_count
from project_budget
where budgetid = p_budgetid
and isdel = 0;
return v_count;
end;
procedure AddProjectBuget(p_returnValue out number,
p_budgetid in varchar2, --项目预算表数据的唯一id
p_projectid in varchar2, --项目id
p_projectname in varchar2, --项目名称
p_expendtime in varchar2, --支出日期
p_usage in varchar2, --用途
p_totalbudget in number, --预算金额(元)
p_spendbudget in number, --支出金额(元)
p_applicant in varchar2, --申请人
p_addperson in varchar2) --创建人
is
v_count number(2);
begin
v_count := JudgeExist(p_budgetid);
if v_count = 0 then
insert into project_budget
(projectid,
projectname,
createtime,
expendtime,
totalbudget,
spendbudget,
applicant,
remainbudget,
usage,
addperson,
isdel)
values
(p_projectid,
p_projectname,
sysdate,
to_date(p_expendtime, 'yyyy-MM-dd'),
p_totalbudget,
p_spendbudget,
p_applicant,
p_totalbudget - p_spendbudget, --剩余金额(元)=预算金额(元)-支出金额(元)
p_usage,
p_addperson,
0);
p_returnValue := 1; --如果添加成功,返回1
else
p_returnValue := -2; --如果添加失败,返回-2
end if;
commit;
exception
when others then
begin
raise_application_error(-20999,
'程序出错,错误代码:' || sqlcode || '错误信息:' ||
sqlerrm);
p_returnValue := -1;
rollback;
end;
end;
-=-=-=-=-=-=-=-=存储过被调用-=-=-=-=-=-=-=-=-=
procedure TestDemo(p_returnValue out number, p_budgetid in varchar2) is
v_count number(2);
begin
select count(1)
into v_count
from vcom_project_budget
where budgetid = p_budgetid
and isdel = 0;
p_returnValue := v_count;
end;
/*
|| 编辑集时通项目预算表
|| lj 2019/12/27
*/
procedure UpdProjectBuget(p_returnValue out varchar2,
p_budgetid in varchar2, --项目预算表数据的唯一id
p_projectid in varchar2, --项目id
p_projectname in varchar2, --项目名称
p_expendtime in varchar2, --支出日期
p_usage in varchar2, --用途
p_totalbudget in number, --预算金额(元)
p_spendbudget in number, --支出金额(元)
p_applicant in varchar2, --申请人
p_modityperson in varchar2) --修改人
is
v_count number(2);
begin
-- v_count := JudgeExist(p_budgetid);
TestDemo(p_returnValue => v_count, p_budgetid => p_budgetid);
if v_count = 0 then
p_returnValue := -2; --如果不存在就无法修改,返回-2
return;
end if;
update project_budget
set projectid = p_projectid,
projectname = p_projectname,
expendtime = to_date(p_expendtime, 'yyyy-MM-dd'),
usage = p_usage,
totalbudget = p_totalbudget,
spendbudget = p_spendbudget,
remainbudget = p_totalbudget - p_spendbudget, --剩余金额(元)=预算金额(元)-支出金额(元)
applicant = p_applicant,
modityperson = p_modityperson,
modityptime = sysdate
where budgetid = p_budgetid;
p_returnValue := 1; --修改成功,返回1
commit;
exception
when others then
begin
raise_application_error(-20999,
'程序出错,错误代码:' || sqlcode || '错误信息:' ||
sqlerrm);
p_returnValue := -1;
rollback;
end;
end;