sql%rowcount用于记录修改的条数,就如你在sqlplus下执行delete from之后提示已删除xx行一样,这个参数必须要在一个修改语句和commit之间放置,否则你就得不到正确的修改行数. 例如: declare n number; begin insert into test_a select level lv from dual connect by level<500; n:=sql%rowcount; commit; dbms_output.put_line(n); end
get diagnostics cnt := row_count; 现在有两个表tab1和tab2,两个表的格式相同,tab1中有1000条数据,tab2中0条数据 创建测试功能函数 create or replace function test_fun() return integer as $body$ declare rowcnt integer; begin insert into tab2 select * from tab1; get diagnostics rowcnt := ro
Oracle 存储过程 删除表记录时删除不存在的记录也是显示删除成功 create or replace procedure delDept(p_deptno in dept.deptno%type) is begin delete from dept where deptno=p_deptno; dbms_output.put_line('部门删除成功...'); exception when others then dbms_output.put_line('部门删除失败...'); en
sql server中,返回影响行数是:If @@RowCount<1 Oracle中,返回影响行数是:If sql%rowcount<1 例: sqlserver: create procedure Proc_test , )='', AS BEGIN Update T_Mt Set Stat=@Stat,OStat=@Stat,RptTime=Getdate() Where MsgId=@MsgId --没有更新成功就插入到t_Statbuf insert into t_statbuf(M