Hello good people of the SQL Programming forum!
I have an SQL 2000 database with a Company table. When a certain field changes from "Prospect" to "Customer", I wish to insert the record into a FoxPro 2.6a table. I have set up a linked server to the FoxPro database.
I have written a stored procedure that does the copying of information from the SQL database to the FoxPro database. This works excellently when called from Query Analyzer.
However, to do this automatically when the status changes from "Prospect" to "Customer", I wrote an update trigger for the Company table that calls the stored procedure. However, I get the following error when I now try to update the Company record:
What I have tried so far:
1. Add SET XACT_ABORT ON at the beginning of the update trigger
2. Tried the various suggestions in Microsoft articles 306212, 329332, 839279
I have an SQL 2000 database with a Company table. When a certain field changes from "Prospect" to "Customer", I wish to insert the record into a FoxPro 2.6a table. I have set up a linked server to the FoxPro database.
I have written a stored procedure that does the copying of information from the SQL database to the FoxPro database. This works excellently when called from Query Analyzer.
However, to do this automatically when the status changes from "Prospect" to "Customer", I wrote an update trigger for the Company table that calls the stored procedure. However, I get the following error when I now try to update the Company record:
I think I understand that the problem is that inside a trigger there is an implicit transaction going on, but FoxPro doesn't support transactions and thus it fails. I think this would work if I could specify not to use a transaction, but I don't know how to override the implicit transaction in the trigger. I don't need it to be a transaction - either the record is added to the FoxPro database or it isn't, so I don't need to do rollbacks, etc.Server: Msg 7391, Level 16, State 1, Procedure proc_AddCustToScheduler, Line 87
The operation could not be performed because the OLE DB provider 'MSDASQL' was unable to begin a distributed transaction.
[OLE/DB provider returned message: [Microsoft][ODBC Visual FoxPro Driver]Driver not capable]
OLE DB error trace [OLE/DB Provider 'MSDASQL' ITransactionJoin::JoinTransaction returned 0x8004d00a].
What I have tried so far:
1. Add SET XACT_ABORT ON at the beginning of the update trigger
2. Tried the various suggestions in Microsoft articles 306212, 329332, 839279
Code:
CREATE TRIGGER trig_CompanyUpdate ON [dbo].[Company]
FOR UPDATE
AS
DECLARE @OldStatus nchar(40),
@CurrentStatus nchar(40),
@CompanyID int,
@CustID nchar(12)
SET XACT_ABORT ON
SELECT @CurrentStatus = Comp_Type, @CompanyID = Comp_CompanyID, @CustID = Comp_IdCust
FROM Inserted
SELECT @OldStatus = Comp_Type FROM Deleted
IF (@OldStatus <> @CurrentStatus) AND (LTRIM(RTRIM(@CurrentStatus)) = 'Customer') AND (@CustID IS NOT NULL)
BEGIN
EXEC proc_AddCustToScheduler @CompanyID, @CustID
END
SET XACT_ABORT OFF