Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
purisqlserver
Yak Posting Veteran
73 Posts |
Posted - 2003-04-28 : 04:52:37
|
| Hi,Whts the alternative to "for each row" in oracle for sql server 2K.This is used within the trigger(for banking transactions).Cursor is the only way?create or replace trigger trig_accafter insert or update on accountsfor each rowdeclare acc accounts.aid%type; attyp accounts.atid%type; vcusid customer.cid%type; bal customer.opbal%type; dat customer.opdate%type; intid interest.irid%type;BEGIN acc:=:New.aid; attyp:=:New.atid;intid:=1;if inserting thenvcusid:=:new.cid;elsevcusid:=:old.cid;end if;select opbal into bal from customer where cid=vcusid;select opdate into dat from customer where cid=vcusid;IF attyp=1 THEN insert into savings(savingsid,aid,savingsdate,savingsbal,irid) values (sav.nextval,acc,dat,bal,intid);ELSIF attyp=2 THEN insert into currentac(currentid,aid,currentdate,currentbal) values (cur.nextval,acc,dat ,bal);END IF;END;Thanx..... |
|
|
Andraax
Aged Yak Warrior
790 Posts |
Posted - 2003-04-28 : 05:01:23
|
| Hello!In the trigger, you can access two logical tables: inserted and deleted. These tables contain the rows which are being inserted, deleted or updated. This allows you to manipulate the data or do integrity checks.Look up "CREATE TRIGGER" in BOL for more information and syntax. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
|
|
|
|
|
|
|