返回的是修改的行数为1,在插入没成功的时候,也反回行数为1. 我的触发器是这样写的 SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO ALTER trigger Insert_xfjl_max on xfjl for insert as if ((select sum(xfje) from xfjl where datepart(dd,xfsj)=day(getdate()) and datepart(m,xfsj)=month(getdate()) and datepart(yyyy,xfsj)=year(getdate()) and kpbh = (select kpbh from inserted))> 50) Rollback else commit GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO
statement三个方法解释:
executeQuery(查询语句),返回resultSet结果集
executeUpdate(DML/DDL语句),返回的是受影响的数据库行数
execute(sql语句),返回为boolean,
1、TRUE表示该语句是执行查询,可以用getResultSet 获得结果集
2、False表示该语句执行修改,可以用getUpdateCount()返回受修改的行数
我的触发器是这样写的
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
ALTER trigger Insert_xfjl_max
on xfjl
for insert
as
if ((select sum(xfje) from xfjl where datepart(dd,xfsj)=day(getdate()) and datepart(m,xfsj)=month(getdate()) and datepart(yyyy,xfsj)=year(getdate()) and kpbh = (select kpbh from inserted))> 50)
Rollback
else
commit
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO