473,394 Members | 1,724 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,394 software developers and data experts.

Getting latest record from trigger

1
Hello,

I have the following table (UNIQUOTE) with data in it:

Opportunity_Id Rx_Combo Plan_Type
B6FG3JX5G $27/$48/$28 HMO
B6FG3JX5G $88/$33/$99 HMO
B6FG3JX5G $16/$17/$18 HMO

There is a trigger on the table that updates another table (opport) on insert. The problem is that if I have an update to make to Rx_Combo it always grabs the first record no matter what. Any ideas on how to get it to update with the current/latest record data? I've looked into SCOPE_IDENTITY() but it can't get it to work. Any ideas? Here's the trigger:

CREATE TRIGGER [update_opportunity_hmo] ON [dbo].[UNIQUOTE]
FOR INSERT
AS
update opport set
opport.HMO_COMP_RX_COPAY=UNIQUOTE.rx_combo,
from opport, UNIQUOTE
where UNIQUOTE.opportunity_id=opport.id
and uniquote.plan_type='HMO'
Jul 23 '07 #1
1 1523
ck9663
2,878 Expert 2GB
Hello,

I have the following table (UNIQUOTE) with data in it:

Opportunity_Id Rx_Combo Plan_Type
B6FG3JX5G $27/$48/$28 HMO
B6FG3JX5G $88/$33/$99 HMO
B6FG3JX5G $16/$17/$18 HMO

There is a trigger on the table that updates another table (opport) on insert. The problem is that if I have an update to make to Rx_Combo it always grabs the first record no matter what. Any ideas on how to get it to update with the current/latest record data? I've looked into SCOPE_IDENTITY() but it can't get it to work. Any ideas? Here's the trigger:

CREATE TRIGGER [update_opportunity_hmo] ON [dbo].[UNIQUOTE]
FOR INSERT
AS
update opport set
opport.HMO_COMP_RX_COPAY=UNIQUOTE.rx_combo,
from opport, UNIQUOTE
where UNIQUOTE.opportunity_id=opport.id
and uniquote.plan_type='HMO'

try getting the value from inserted/deleted tables
Jul 23 '07 #2

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

Similar topics

3
by: IndianaJonesWB | last post by:
I'm trying to figure out what happened. I have have two Tables in SQLServer called "Contacts", and "Jobs" Whenever someone changes a record in either table I update two fields called "Modby"...
5
by: Dave Sisk | last post by:
Hey folks: I'm trying to do this: CREATE TRIGGER datawhse.emp_ti AFTER INSERT ON emp REFERENCING NEW AS n FOR EACH ROW MODE DB2ROW BEGIN DECLARE v_rrn DECIMAL(15,0);
1
by: Steve Leferve | last post by:
Hey folks - I have some VBA code for creating a row and related sub-rows from a 'wizard' form. I'm using sql 'INSERT' statements to create the rows. My problem is that I need to get the...
1
by: James P. | last post by:
Hello, In my SQL table, I currently have a trigger to send email when a new record (from MS Access 2000 form) is inserted into the table. It works fine. The problem is sometimes when Exchange...
20
by: Bryan | last post by:
hello all... im trying to add a record to an sql db on ms sql server 2000, using vb.net. seems to be working.. except for one thing, one of the columns in the database is a bit datatype, and...
3
by: Jim Archer | last post by:
Hi All... I'm been fighting this problem for a few days now, and it seems like it should be simple. But the solution has eluded me so far... I need to flag a record when it is updated or when...
5
by: alanspamenglefield | last post by:
Hello group, I have an SQL statement which pulls data from a table as follows: " SELECT tblSites.sites_siteno, " & _ " tblSites.sites_sitename, " & _ " Sum(tblStockResults.stkr_result) AS...
0
by: babayemi | last post by:
Am in a small fix. my Trigger is updating all my entire table records , i don't want that, i want to update a column in the record that is updated by my application using a trigger that tracks...
8
by: narpet | last post by:
Hello all... I'm having a problem getting a query to work. As a matter of fact I can't even seem to get a good start. I have a table with the following example data ID# PRE_ID# ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
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...

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.