谁能给个ORACLE存储过程开发的关于表的增删改操作的例子,
最好带参数和返回值,有游标和行类型更好,如果带上JAVA调用更好,

解决方案 »

  1.   

    --对表t_work_list进行插入或者修改操作
    create or replace procedure pre_modify_work(
       in_moveid in char,
       in_ID in VARCHAR2,
       in_CNTRNO in VARCHAR2,
       in_VOYAGEKEY in VARCHAR2,
       in_FULLID in CHAR,
       in_SIZ in VARCHAR2,
       in_CNTRTPY in VARCHAR2,
       in_CARRIER in VARCHAR2,
       in_CNTROWN in VARCHAR2,
       in_SOC in CHAR,
       in_BAYNO in VARCHAR2,
       in_IS_AUTO in CHAR
       )
    is
       is_worklistno varchar2(20);
       is_exists number(1,0);
       is_fullid varchar2(5);
       is_listtyp varchar(20);
       is_seqno number;
    begin   is_fullid:='E';
       if in_fullid='LCL' or in_fullid='FCL' then
          is_fullid:='F';
       end if;
       
       if in_moveid='10' then
          is_listtyp:='移箱_上车';
       end if;   
       if in_moveid='11' then
          is_listtyp:='移箱_下车';
       end if;
       
       begin
          select count(*) into is_exists
          from t_work_list
          where id=in_id;
       exception when no_data_found then   
          is_exists:=0;
       end;
       
       begin
          select worklistno into is_worklistno
          from worklist;
       exception when no_data_found then   
          is_worklistno:='';
       end;
       
       begin
          select max(seqno)+1 into is_seqno
          from t_work_list
          where worklistno=is_worklistno;
       exception when no_data_found then
          is_seqno:=1;
       end;
    --如果记录不存在,则插入
       if is_exists=0 then
          insert into t_work_list
               (id,worklistno,cntrno,listtyp,voyagekey,seqno,
         fullid,siz,cntrtpy,carrier,cntrown,soc,bayno,is_auto) 
         values(in_id,is_worklistno,in_cntrno,is_listtyp,in_voyagekey,is_seqno,
         in_fullid,in_siz,in_cntrtpy,in_carrier,in_cntrown,in_soc,in_bayno,in_is_auto);
       end if;
    --如果记录存在则修改
       if is_exists>0 then
          begin
             update t_work_list
                set worklistno=is_worklistno,cntrno=in_cntrno,listtyp=is_listtyp,voyagekey=in_voyagekey,
                    seqno=is_seqno,fullid=in_fullid,siz=in_siz,cntrtpy=in_cntrtpy,carrier=in_carrier,
             cntrown=in_cntrown,soc=in_soc,bayno=in_bayno,is_auto=in_is_auto
             where id=in_id;
          exception when no_data_found then
             return;
          when others then
             return;
          end;
       end if;
    end;
    /
    show errors
    我以前写的一个,不知道能不能适合你