判断表CURRENTBRANCHSTATISTIC(总共两个字段BRANCH_ID,INNUM)中记录是否存在,存在则更新,不存在则插入!
1 create or replace procedure CURRENTBRANCHSTATISTIC_INSERT(M_BRANCH_ID in NVARCHAR2, 2 M_INNUM in NUMBER) is 3 recordnum NUMBER:=0; 4 begin 5 select count(BRANCH_ID) into recordnum from CURRENTBRANCHSTATISTIC Where BRANCH_ID=M_BRANCH_ID; 6 if(recordnum=0) then 7 insert into CURRENTBRANCHSTATISTIC(BRANCH_ID,INNUM) values (M_BRANCH_ID,M_INNUM); 8 Else 9 update CURRENTBRANCHSTATISTIC set INNUM=M_INNUM where BRANCH_ID=M_BRANCH_ID; 10 End if; 11 end CURRENTBRANCHSTATISTIC_INSERT;
调用代码:
1 begin 2 CURRENTBRANCHSTATISTIC_INSERT('111',198); 3 end;