oracle10g 创建存储过程的一个实例:
知识点:
1.游标
2.if语句的写法(注意是elsif,不要忘记写then)
3.变量的赋值 :=
create or replace procedure p_settlement_checkData(supplier in varchar2,buyer in varchar2,startDate in varchar2,endDate in varchar2,checkperson in varchar2) as
--定义游标
cursor c_diff_saleData is
--此处写入查询脚本
--定义保存游标数据变量
v_diff_data c_diff_saleData%rowtype;
v_cn int;
v_isExist boolean;
begin
-- 打开游标
open c_diff_saleData;
loop
--遍历游标
fetch c_diff_saleData into v_diff_data;
exit when c_diff_saleData % notfound;
v_isExist := false;
if( v_diff_data.sorderId is null and v_diff_data.borderId is not null) then
select count(*) into v_cn from checkedData where borderId = v_diff_data.borderId;
if(v_cn = 0) then
v_isExist := false;
else
v_isExist := true;
end if;
elsif( v_diff_data.sorderId is not null and v_diff_data.borderId is null) then
DBMS_OUTPUT.PUT_LINE("output");
else
DBMS_OUTPUT.PUT_LINE("output");
end if;
end loop;
close c_diff_saleData;
end p_settlement_checkData;
/
知识点:
1.游标
2.if语句的写法(注意是elsif,不要忘记写then)
3.变量的赋值 :=
create or replace procedure p_settlement_checkData(supplier in varchar2,buyer in varchar2,startDate in varchar2,endDate in varchar2,checkperson in varchar2) as
--定义游标
cursor c_diff_saleData is
--此处写入查询脚本
--定义保存游标数据变量
v_diff_data c_diff_saleData%rowtype;
v_cn int;
v_isExist boolean;
begin
-- 打开游标
open c_diff_saleData;
loop
--遍历游标
fetch c_diff_saleData into v_diff_data;
exit when c_diff_saleData % notfound;
v_isExist := false;
if( v_diff_data.sorderId is null and v_diff_data.borderId is not null) then
select count(*) into v_cn from checkedData where borderId = v_diff_data.borderId;
if(v_cn = 0) then
v_isExist := false;
else
v_isExist := true;
end if;
elsif( v_diff_data.sorderId is not null and v_diff_data.borderId is null) then
DBMS_OUTPUT.PUT_LINE("output");
else
DBMS_OUTPUT.PUT_LINE("output");
end if;
end loop;
close c_diff_saleData;
end p_settlement_checkData;
/