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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Migrate from Oracle trigger to MSSQL trigger

Author  Topic 

nha001
Starting Member

2 Posts

Posted - 2014-03-11 : 01:36:00
Hi I am new to MSSQL server. I have problem in migration from ORACLE trigger to MSSQL server. Here below the trigger in Oracle..

<<--------Trigger Begin----------->>

create or replace
TRIGGER transactiontrigger After INSERT ON ORDERINVOICE
FOR EACH ROW
BEGIN
update A_ACCOUNT
set A_ACCOUNT.AC_RUNNING_BLC=(A_ACCOUNT.AC_RUNNING_BLC-:new.NETAMMOUNT+:new.COMMISION-:new.TDS)
where A_ACCOUNT.A_ID=:new.A_ID;
END;

<<---------Trigger END-------->>


Could you some one help me to transform the trigger in MSSQL compatible.

Nilotpalhazarika

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-03-11 : 05:24:23
in MS SQL trigger would be as below

create TRIGGER transactiontrigger
ON ORDERINVOICE
After INSERT
AS
BEGIN
update a
set a.AC_RUNNING_BLC=(a.AC_RUNNING_BLC - i.NETAMMOUNT + i.COMMISION - i.TDS)
FROM A_ACCOUNT a
INNER JOIN INSERTED i
ON i.A_ID= a.A_ID
END;


MS SQL triggers work on basis of two internal table INSERTED and DELETED which will contain old/new values

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

nha001
Starting Member

2 Posts

Posted - 2014-03-11 : 09:15:26
Thank you for you help!

Nilotpalhazarika
Go to Top of Page
   

- Advertisement -