bustercoder
Programmer
- Mar 13, 2007
- 96
Hello,
I have this trigger which inserts a line for a freight amount into another table, but I need to update two fields with the same value. This value for the freight amount only comes in as one column from the source table. Is there a way to populate the second field with that value? The first value (SOP10102.CRDAMT) populates fine with the FREIGHT_AMOUNT, but the next column (SOP10102.ORCRDAMT) returns a "does not allow nulls" error, and making that column to allow nulls is not an option. You can see from my trigger below how I have the FRIEGHT_AMOUNT in twice, because I thought I could map it however many times I needed to whatever fields I needed.
(CREATE TRIGGER [dbo].[trig_insertFreightLine] ON dbo.Test_Shipments_Import
FOR INSERT, UPDATE, DELETE
AS
begin
SET NOCOUNT ON
if exists (select * from deleted)
begin
delete SOP10102
from SOP10102 ifl inner join
deleted on (ifl.SOPNUMBE = deleted.ORDER_ID)
end
if exists (select * from inserted)
begin
insert SOP10102
select distinct 3, ORDER_ID, 100, 7, '', 83, 0, 0, FREIGHT_AMOUNT, FREIGHT_AMOUNT, 2999, '', 0
from inserted
end
end
Thanks,
Buster
I have this trigger which inserts a line for a freight amount into another table, but I need to update two fields with the same value. This value for the freight amount only comes in as one column from the source table. Is there a way to populate the second field with that value? The first value (SOP10102.CRDAMT) populates fine with the FREIGHT_AMOUNT, but the next column (SOP10102.ORCRDAMT) returns a "does not allow nulls" error, and making that column to allow nulls is not an option. You can see from my trigger below how I have the FRIEGHT_AMOUNT in twice, because I thought I could map it however many times I needed to whatever fields I needed.
(CREATE TRIGGER [dbo].[trig_insertFreightLine] ON dbo.Test_Shipments_Import
FOR INSERT, UPDATE, DELETE
AS
begin
SET NOCOUNT ON
if exists (select * from deleted)
begin
delete SOP10102
from SOP10102 ifl inner join
deleted on (ifl.SOPNUMBE = deleted.ORDER_ID)
end
if exists (select * from inserted)
begin
insert SOP10102
select distinct 3, ORDER_ID, 100, 7, '', 83, 0, 0, FREIGHT_AMOUNT, FREIGHT_AMOUNT, 2999, '', 0
from inserted
end
end
Thanks,
Buster