Re: ICommandText.Execute on table with trigger returns wrong RowsAffected?
- From: "mocarts" <helmuts@xxxxxxxxxxxx>
- Date: Sun, 12 Jun 2005 09:48:36 +0300
Thank You for your replay Erland!
That's what I have done - I'm using IMultipleResults and the last one (after
all trigger statements are executed) is the one I need.
But I'm trying to understand why Execute returns value of RowsAffected not
related to the statement I execute (there wasn't problem with DB-Lib with
this). Maybe there is some property I can set or specific SP needed?
mocarts
"Erland Sommarskog" <esquel@xxxxxxxxxxxxx> wrote in message
news:Xns9671E34C0DEE5Yazorman@xxxxxxxxxxxx
> mocarts (helmuts@xxxxxxxxxxxx) writes:
> > I'm trying to understand is this feature or bug when inserting, updating
> > table with trigger, RowsAffected parameter is set to last trigger's
> > executed statement affected rows count.
> > example:
> > stmt: INSERT INTO TEST (PK, VAL) VALUES (1, 2)
> >
> > and trigger:
> > create trigger TESTBUG on TEST
> > for insert, update, delete
> > as
> > begin
> > UPDATE TEST SET PK=PK WHERE 1=2
> > end
> >
> > in this case when executing stmt RowsAffected returns 0. without trigger
> > or with SET NOCOUNT ON in the trigger there is correct result - 1 how I
> > can make sure that smt is succeeded? especially that is important in
> > case of update (examp. UPDATE TEST SET VAL=VAL+1 WHERE PK=1)..
>
> You could have a SET NOCOUNT ON in the trigger, to suppress that rowcount.
> However, that helps you little if you don't have full control over the
> database.
>
> The other solution is to use IMultipleResults. The you will get
> one rowset object for each rowcount, and you will have to know that
> the first rowcount is the one you are looking for. You still will
> have to sift through the remaining rowsets.
>
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx
>
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
.
- Follow-Ups:
- Re: ICommandText.Execute on table with trigger returns wrong RowsAffected?
- From: Erland Sommarskog
- Re: ICommandText.Execute on table with trigger returns wrong RowsAffected?
- References:
- ICommandText.Execute on table with trigger returns wrong RowsAffected?
- From: mocarts
- Re: ICommandText.Execute on table with trigger returns wrong RowsAffected?
- From: Erland Sommarskog
- ICommandText.Execute on table with trigger returns wrong RowsAffected?
- Prev by Date: Re: ICommandText.Execute on table with trigger returns wrong RowsAffected?
- Next by Date: Rowset properties
- Previous by thread: Re: ICommandText.Execute on table with trigger returns wrong RowsAffected?
- Next by thread: Re: ICommandText.Execute on table with trigger returns wrong RowsAffected?
- Index(es):
Relevant Pages
|
|