• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 140
  • Last Modified:

I have an update trigger that grabs the qty value from inserted, this value is always double what was inserted by the end user?

The update trigger grabs one field, the qty field and inserts into a table created by us.  The value is always double what was entered.  Please help.
0
steven
Asked:
steven
  • 2
  • 2
1 Solution
 
stevendeveloperAuthor Commented:
here is a the insert?


                  

if (Update(qty_ordered))
Begin            
             
insert into PUt_qtychange (conum,coline,udpatedby,qtyorderd,price)

select     item,
                     co_num,
                     co_line,
                   updatedby,
               qty_ordered,
               price
      from      inserted

end
0
 
OriNetworksCommented:
Are you sure you are only inserting one line? Watch out for where it may be inserting multiple lines or where that may happen in the future.
0
 
stevendeveloperAuthor Commented:
I only update the qty and then checked the table only one line is inserted.
0
 
OriNetworksCommented:
What exactly are you trying to accomplish with this trigger and what is the name of the table that this trigger is on?

If this trigger is on table PUt_qtychange  and you are also telling it to insert to PUt_qtychange, then yes, of course your records will be doubled because for each insert you are telling the trigger to insert again.

Additionally, you can use SQL Profiler to see exactly what values are being passed to update the table.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now