select * from aaa ;是SQL语句
首先要明确你写这个PROCEDURE 的目的是什么?
‘要选出所有的纪录’:那么用游标实现:
create or replace procedure sel_aaa
is
cursor cr is select a,b,cfrom aaa;
begin
-------你的过程体,对cr 进行调用。
end sel_aaa;
PS:给你参考
procedure plan_cancel (v_plan varchar2) is
cursor cr is select materiel_code,parts_num from plan_destine where plan_no=v_plan;
v_num number;
begin
--------ÐèÒªÐ޸ļ¸¸ö¼Æ»®±íºÍ¿â´æ±í PLAN,PLAN_DECOMPOSE,PLAN_DECOMPOSE_TREE,PLAN_DESTINE,PLAN_MATERIEL_REPORT,PLAN_MATERIEL_REPORT_TMP,
------stor±í ¸ù¾ÝPLAN_DESTINE ±íÖеÄÊý¾ÝÁ¿¼õÉÙ STOR ±íÖеÄDESTINE_NUM×Ö¶ÎÊýÁ¿¡£
for cr1 in cr loop
begin
select destine_num into v_num from stor where mate_code=cr1.materiel_code and dept_id=0 ;
exception
when no_data_foundthen
null;
end ;
if v_num >0 then
update stor set destine_num = destine_num - cr1.parts_num where dept_id = 0and mate_code=cr1.materiel_code ;
end if;
commit;
end loop;
-------------------------------,PLAN_MATERIEL_REPORT_TMP1,PLAN_MATERIEL_REPORT_TMP2,STOR
end ;
|