OT: SQL trigger question

"Syed.Alam" <[email protected]> Fri, 2 Aug 2002 14:32:24 -0500
Newsgroups gmane.comp.windows.devel.oledb.devel
Message-ID <[email protected]>
Hi

Sorry for the OT (somewhat related), and excuse me of this is really a dumb
question.

I have an INSERT trigger on table tab.  The insert operation on this table
is like

insert into tab  (col1, col2 )
select A.col1, 0 from tab A
where A.col2 = 2


The trigger is like:

CREATE TRIGGER tr_tab1
ON tab1
FOR INSERT
AS

BEGIN
 DECLARE @col1 int
 DECLARE @col2 int


 SELECT @col1 = col1,
  @col2 = col2
 FROM inserted

 if ( @col2 = 0 )
      insert into tab2 values (@col1+1)
End


The trigger is called once with a rowset containing all rows to be included.
How can I parse thru all the rows (just like we do in ADO, like MoveNext()
)?

Right now, as u can see in the trigger, only the last row is being dealt
with. I can do like

insert into tab2 (...)
select ... from inserted

but i want to parese thru the resultset (in a loop)


Thanks





You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.