[Emerald] triggers

Emad Hazza ( (no email) )
Thu, 27 Apr 2000 12:49:54 +0300

Hi All

I applied the followin trigger to the masteraccounts table to write
all the transactions on the masteraccounts table to another table which
is called masteraccounts2. but now when I do updates to the master from
emerald I get SQL FAIL ERROR

if exists (select * from sysobjects where id = object_id('dbo.tracerm')
and sysstat & 0xf = 8)
drop trigger dbo.tracerm
GO

CREATE TRIGGER tracerm ON dbo.MasterAccounts
FOR INSERT, DELETE ,UPDATE
as
insert into MasterAccounts2
select m.*
from inserted i , MasterAccounts m
where

i.customerid = m.customerid

GO
***********************************************************
drop table masteraccounts2
GO

CREATE TABLE MasterAccounts2
(
CustomerID int ,
ReferredBy varchar (25) NULL ,
FirstName varchar (25) NOT NULL ,
LastName varchar (25) NOT NULL ,
Company varchar (35) NULL ,
Address1 varchar (50) NULL ,
Address2 varchar (50) NULL ,
City varchar (25) NULL ,
State varchar (3) NULL ,
Zip varchar (12) NULL ,
PhoneHome varchar (20) NULL ,
PhoneWork varchar (20) NULL ,
PhoneFax varchar (20) NULL ,
SalesPerson varchar (25) NULL ,
Region varchar (15) NOT NULL DEFAULT ('Unknown') REFERENCES
Regions(Region),
CreateDate datetime NOT NULL DEFAULT (getdate()) ,
StartDate datetime NOT NULL DEFAULT (getdate()) ,
maExpireDate datetime NULL DEFAULT (NULL) ,
Extension int NOT NULL DEFAULT 0 ,
Active bit NOT NULL DEFAULT 1,
PayPeriod varchar (12) NOT NULL DEFAULT ('Annually') REFERENCES
PayPeriods(PayPeriod),
PayMethod varchar (15) NOT NULL DEFAULT (' Invoice') REFERENCES
PayMethods(PayMethod),
PayInfo varchar (50) NULL ,
PaidThru datetime NOT NULL DEFAULT (getdate()) ,
LastReceived datetime NOT NULL DEFAULT (getdate()) ,
PONumber varchar (17) NULL ,
PrePaid varchar (7) NULL ,
CreditCardNumber varchar (20) NULL ,
CreditCardExpire varchar (6) NULL ,
CreditCardAuth varchar (40) NULL ,
CreditCardAutoBill bit NOT NULL DEFAULT 0,
Comments text NULL ,
LastModifyDate datetime NOT NULL DEFAULT (getdate()) ,
LastModifyUser varchar (15) NOT NULL DEFAULT USER,
maCurrent bit NOT NULL DEFAULT 0,
maNew bit NOT NULL DEFAULT 1,
GroupID int NOT NULL DEFAULT 1 REFERENCES Groups(GroupID),
Balance money NULL DEFAULT 0,
OverDue tinyint NULL DEFAULT 0,
SendMethod tinyint NULL DEFAULT 0,
OverLimit Money NULL DEFAULT NULL,
Taxable bit NOT NULL DEFAULT 0 ,
BillingCycleID int NULL DEFAULT NULL REFERENCES
BillingCycles(BillingCycleID) ,
BilledThru smalldatetime NULL DEFAULT NULL
)
GO

For more information about this list (including removal) go to:
http://www.iea-software.com/support/maillists/liststart