473,320 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Converting a trigger in Oracle to SQLserver

I have a trigger in oracle. I need to convert it into SQL server. Can anyone help me. This is the trigger to be converted.
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE TRIGGER TR_MYTRIGGER AFTER UPDATE ON TB_USER
  2. FOR EACH ROW
  3.     DECLARE       
  4.     cursor curIStl is       
  5.         SELECT * FROM    TB_USER  WHERE              CFIN_YEAR=:NEW.CFIN_YEAR AND NDEP_NO=:NEW.NDEP_NO;
  6.            rtIStl curIStl%rowtype;
  7.     BEGIN    
  8.         IF :NEW.NCANCELLED <> :OLD.NCANCELLED THEN
  9.              Open curIStl ;
  10.              Loop          
  11.                 Fetch curIStl into rtIStl;      
  12.                 exit when curIStl%notfound;       
  13.                 IF :NEW.NCANCELLED=1 AND :OLD.NCANCELLED=0 THEN                 
  14.                     UPDATE USER_SAL SET NAMT = NAMT + rtIStl.INC                        WHERE DEP_CODE = rtIStl.NDEP_NO ;                    END IF;     
  15.             End Loop;     
  16.             close curIStl;   
  17.         END IF;
  18.     END;
Nov 12 '07 #1
1 2152
amitpatel66
2,367 Expert 2GB
I have a trigger in oracle. I need to convert it into SQL server. Can anyone help me. This is the trigger to be converted.
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE TRIGGER TR_MYTRIGGER AFTER UPDATE ON TB_USER
  2. FOR EACH ROW
  3.     DECLARE       
  4.     cursor curIStl is       
  5.         SELECT * FROM    TB_USER  WHERE              CFIN_YEAR=:NEW.CFIN_YEAR AND NDEP_NO=:NEW.NDEP_NO;
  6.            rtIStl curIStl%rowtype;
  7.     BEGIN    
  8.         IF :NEW.NCANCELLED <> :OLD.NCANCELLED THEN
  9.              Open curIStl ;
  10.              Loop          
  11.                 Fetch curIStl into rtIStl;      
  12.                 exit when curIStl%notfound;       
  13.                 IF :NEW.NCANCELLED=1 AND :OLD.NCANCELLED=0 THEN                 
  14.                     UPDATE USER_SAL SET NAMT = NAMT + rtIStl.INC                        WHERE DEP_CODE = rtIStl.NDEP_NO ;                    END IF;     
  15.             End Loop;     
  16.             close curIStl;   
  17.         END IF;
  18.     END;
Check here for detail on MS SQL trigger
Nov 12 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Mark Townsend | last post by:
Following is a summary of articles spanning a 7 day period, beginning at 23 Feb 2004 05:29:19 GMT and ending at 01 Mar 2004 04:12:14 GMT. Notes ===== - A line in the body of a post is...
1
by: Mike Landis | last post by:
Hello, Has anyone a small tool or somekind of document which could help me to convert Oracle SQL scripts to SQL Server? Scripts are not very Oracle specified. Thanks, Below is a Script...
4
by: Pecos Bill | last post by:
Salve, non riesco a disabilitare un trigger su sqlserver nè da query analyzer, nè da enterprise manager. In pratica tal cosa riuscivo a farla in Oracle con TOAD, mentre qui non riesco. Mi...
1
by: efinney | last post by:
Hi, I'm a newbie to sql server and this may be a really dumb question for some you. I'm trying to find some examples of sql server triggers that will set columns (e.g. the created and modified...
19
by: DW | last post by:
Hi, all... I have a sizeable database running under Oracle 9.2.0.4 under AIX 5.2.0. I am faced with an impending move to a Windows environment, running under SQL 2000. Currently, we are...
4
by: Jim Devenish | last post by:
We have an Access database with Access front-end to Access back-end. Another company has installed a separate application using SQLServer. At present certain information in the first application is...
2
by: sumithsumith | last post by:
Hi Friends, i need ur help for creating a update/delete trigger in sqlserver.i am having two tables.If i delete/update data of one table,that data should be stored in the second table.how...
8
by: candide_sh | last post by:
hello, I googled around some time but I found no solution for this issue (SS2000). I have a table tblB which has to be filled whenever in table tblA records are inserted, updated or deleted....
11
by: tracy | last post by:
Hi, I really need help. I run this script and error message appeal as below: drop trigger log_errors_trig; drop trigger log_errors_trig ERROR at line 1: ORA04080: trigger 'LOG_ERRORS-TRIG'...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.