oracle数据库:业务数据处理之三
一、任务
7\客户提出在采购单据修改的时候,可以重新选择供应商或者修改备注信息来修改采购单的信息
8\编写根据采购单单号审核采购单的过程,根据输入的采购单号,将采购单的状态列值修改为'2'(已审核),但是需要检查,如果修改之前采购单的状态值已经为'2',就提示错误信息:“XXXXX单据已经审核”
二、脚本
7\create or replace procedure p_updatemainprocure
(i_pmid t_main_procure.pmid%type,
i_sid t_main_procure.sid%type default 'SID',
i_pmemo t_main_procure.pmemo%type default 'PMEMO')
as
begin
if i_sid='SID' and i_pmemo!='PMEMO' then
update t_main_procure set pmemo=i_pmemo where pmid=i_pmid;
dbms_output.put_line('您成功修改了'||i_pmid||'单据的备注信息');
elsif i_sid!='SID' and i_pmemo!='PMEMO' then
update t_main_procure set sid=i_sid where pmid=i_pmid;
dbms_output.put_line('您成功修改了'||i_pmid||'单据的供应商信息');
elsif i_sid!='SID' and i_pmemo!='PMEMO' then
update t_main_procure set sid=i_sid,pmemo=i_pmemo where pmid=i_pmid;
dbms_output.put_line('您成功修改了'||i_pmid||'单据的供应商和备注信息');
else
dbms_output.put_line('您没有需要修改的信息');
end if;
commit;
exception
when others then
dbms_output.put_line(sqlerrm||'执行错误');
rollback;
end;
8\create or replace procedure p_checkmainprocure
(i_pmid t_main_procure.pmid%type) as
v_pstate char;
begin
select pstate into v_pstate from t_main_procure where pmid=i_pmid;
if v_pstate='2' then
raise_application_error(-20012,i_pmid||'单据已经审核!');
else
update t_main_procure set pstate='2' where pmid=i_pmid;
end if;
exception
when others then
dbms_output.put_line(SQLERRM);
end;
三、相关
1、调用存储的方法有几种。如果是没有输出参数的过程调用,可以在SQL*Plus中使用exec 存储过程名(参数);进行调用;对于有输出参数的过程调用,由于需要使用变量存储输出参数,故需要在程序中调用。
2、过程中可以包含程序设计中常用的赋值语句、选择分支结构、select查询语句(必须使用select into将查询结果保存到变量中)、insert语句、update语句、delete语句及事务控制语句,并且可以根据需要设置输入设置、输出参数和输入输出参数,所以可以实现一些较为复杂的业务逻辑的流程处理。
本文来源 我爱IT技术网 http://www.52ij.com/jishu/5116.html 转载请保留链接。
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
