I am working on an update trigger that updates certain columns in table two when table one is updated.
Example If Column a, b, or c is updated in table 1, I need those to be updated in table 2- Column a, b, or c based on the unique identifier column (let's say column a in both tables are the ids). The other problem I have is that for both table there is also a colum D. In Table 1 column d can be = red, blue, or pink. If column d is = red or pink then column d in table 2 needs to be updated to red. If table 1, column d = blue, then column d in table 2 needs to be updated to blue.
Can someone please help me?
3 7556 ck9663 2,878
Recognized Expert Specialist
Can you post what you have so far?
CREATE TRIGGER tr_u_employee ON employee
FOR UPDATE AS
DECLARE @a INT, @b INT, @C INT, @factor INT, @value INT, @columns AS VARCHAR(200), @colname AS VARCHAR(100)
IF ( (SUBSTRING(COLU MNS_UPDATED(),1 ,1) & 70 > 0))
AFTER UPDATE
ON Employee
FOR EACH ROW
-- Update record into Users table
UPDATE Portsl.dbo.User s
( employee_id,
FirstName,
LastName,
Status )
VALUES
( :old.employee_i d,
:new.FirstName,
:new.LastName,
:new.Status );
END;
ck9663 2,878
Recognized Expert Specialist
On update trigger, get the old values from deleted and the new value from inserted tables. These are logical tables created during the update process and only accessible inside the trigger.
Happy coding!
-- CK
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Dave |
last post by:
I have 2 tables, one with names, and another with addresses, joined by their
CIVICID number (unique to the ADDRESSINFO table) in Oracle.
I need to update a field in the NAMEINFO table for a particular surname in a
particular town.
I can select the records fine with this syntax (testing in Oracle SQL* Plus)
SELECT NAMEINFO.LASTNAME, NAMEINFO.FIRSTNAME, NAMEINFO.MIDDLENAME,
NAMEINFO.GENDER, ADDRESSINFO.REGION FROM NAMEINFO, ADDRESSINFO...
|
by: Lauren Quantrell |
last post by:
In VBA, I constructed the following to update all records in
tblmyTable with each records in tblmyTableTEMP having the same
UniqueID:
UPDATE
tblMyTable RIGHT JOIN tblMyTableTEMP ON tblMyTable.UniqueID =
tblMyTableTEMP.UniqueID
SET
tblMyTable.myField = tblMyTableTEMP.myField,
tblMyTable.myField2 = tblMyTableTEMP.myField2,
|
by: Gent |
last post by:
am using FOR UPDATE triggers to audit a table that has 67 fields. My
problem is that this slows down the system significantly. I have
narrowed down the problem to the size (Lines of code) that need to be
compiled after the trigger has been fired. There is about 67 IF
Update(fieldName) inside the trigger and a not very complex select
statement inside the if followed by an insert to the audit table. When
I leave only a few IF-s in the...
|
by: Jan van Veldhuizen |
last post by:
The UPDATE table FROM syntax is not supported by Oracle.
I am looking for a syntax that is understood by both Oracle and SqlServer.
Example:
Table1:
id name city city_id
1 john newyork null
|
by: Derek Erb |
last post by:
SQL Server 2000 : I have a series of tables which all have the same
structure. When any of these tables are modified I need to syncrhonise
all of those modifications with one other table wich is a sort of merge
of the individual tables with one extra column.
For most of these tables this is not a problem. The problem arrives
when one of the tables has an ntext column which obviously can not be
used in an update or insert trigger.
...
| |
by: Sean Shanny |
last post by:
To all,
The facts:
PostgreSQL 7.4.0 running on BSD 5.1 on Dell 2650 with 4GB RAM, 5 SCSI
drives in hardware RAID 0 configuration. Database size with indexes is
currently 122GB. Schema for the table in question is at the end of this
email. The DB has been vacuumed full and analyzed. Between 8 and 12
million records are added to the table in question each night. An
analyze on the entire DB is done after the data has been loaded...
|
by: Bill Smith |
last post by:
The initial row is inserted with the colPartNum column containing a valid
LIKE pattern, such as (without the single quotes) 'AB%DE'.
I want to update the column value with the results of a query against a
different table (that uses the LIKE predicate) but cannot get around the
SQL0132 error .
I have tried the hex notation after the LIKE such as (without the
quotes)...
" where colNewPartNum like ( X'27' || nnn.colPartNum || X'27) " ,...
|
by: rdraider |
last post by:
Hi all,
I know squat about triggers so was hoping somebody could point me in the
right direction. I wanted to copy an email address field from a salesman
table to a note field in a customer table. Seems easy enough for a one time
update. But I would like to add a trigger to auto-update the customer table
anytime an email address changes in the saleman table or a new salesman
record is added.
Here's my update script (this copies the...
|
by: abhi81 |
last post by:
Hello All,
I have a table on which I have created a insert,Update and a Delete trigger. All these triggers write a entry to another audit table with the unique key for each table and the timestamp.
Insert and Update trigger work fine when i have only one of them defined.
However when I have all the 3 triggers in place and when i try to fire a insert query on the statement. It triggers both insert and update trigger at the same time and...
|
by: Microsoft Newsserver |
last post by:
HI
Im developing a solution in vs2005 with ajex extensions. Essentially I have
three custom controls which render tables a representation as shown below.
The problem is that when any of those buttons get clicked all three tables
are updated. ( Buttons 1 2 and 3 are outside the panels ). How can I get
ONLY the
relevent panel to update ??
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |