Oracle sql%rowcount 返回影响行数;sql server @@RowCount返回影响行数

时间:2024-11-10 22:04:38

sql server中,返回影响行数是:If @@RowCount<1

Oracle中,返回影响行数是:If sql%rowcount<1

例:

sqlserver:

create procedure Proc_test
@Stat int=0,
@MsgId varchar(50)='',
AS
BEGIN
Update T_Mt Set Stat=@Stat,OStat=@Stat,RptTime=Getdate() Where MsgId=@MsgId
If @@RowCount<1 --没有更新成功就插入到t_Statbuf
insert into t_statbuf(MsgId,Stat,RptTime) values(@MsgId,@Stat,Getdate())
END

oracle:

CREATE OR REPLACE PROCEDURE test  

AS
BEGIN
update MY_TIME_TEST1 set discript = '' where discript = '' ;
If sql%rowcount>1 then --上面update影响行数>1就插入到my_time_test1
insert into MY_TIME_TEST1 values(sysdate,'');
end if;
END;

参照:http://www.linuxidc.com/Linux/2012-01/51693.htm