I'm having problems with a trigger that should work.
When a row is added to table1 I need to trigger some SQL that goes away to DB2 database and grabs information about the inserted data and adds it to table2
I've developed a procedure using OPENQUERY on a AS400 linked server that works beautifully. It's called GetAdditionalAS400Data. If I open the query analyser and type GetAdditionalAS400Data '12345B' it appends a row to the second table. So now, it should just be a case of calling that procedure from a trigger.
create trigger getAdditionalInformation
on dbo.table1
for INSERT
as
declare @ref char(7)
select @ref = xRef from INSERTED
exec('GetAdditionalAS400Data ''' + @ref + '''')
go
But it doesn't work. I've even tried simplifying things. The line below runs from SQL Server Query Analyser and adds a row to table2.
exec('GetAdditionalAS400Data ''12345''')
But this trigger fails....
alter trigger getAdditionalInformation
on dbo.table1
for INSERT
as
exec('GetAdditionalAS400Data ''12345''')
go
The error message is... ODBC SQL Server Driver OLE/DB Message Returned : AS400 Driver Not Capable. The operation could not be performed because the OLE DB Provider MSDASQL was unable to begin a distributed transaction.
What I don't understand is that it runs fine in SQL Query Analyser???
Should I be using something other than OPENQUERY to retrieve my information from the AS400?
Any ideas?
How would you do this?
When a row is added to table1 I need to trigger some SQL that goes away to DB2 database and grabs information about the inserted data and adds it to table2
I've developed a procedure using OPENQUERY on a AS400 linked server that works beautifully. It's called GetAdditionalAS400Data. If I open the query analyser and type GetAdditionalAS400Data '12345B' it appends a row to the second table. So now, it should just be a case of calling that procedure from a trigger.
create trigger getAdditionalInformation
on dbo.table1
for INSERT
as
declare @ref char(7)
select @ref = xRef from INSERTED
exec('GetAdditionalAS400Data ''' + @ref + '''')
go
But it doesn't work. I've even tried simplifying things. The line below runs from SQL Server Query Analyser and adds a row to table2.
exec('GetAdditionalAS400Data ''12345''')
But this trigger fails....
alter trigger getAdditionalInformation
on dbo.table1
for INSERT
as
exec('GetAdditionalAS400Data ''12345''')
go
The error message is... ODBC SQL Server Driver OLE/DB Message Returned : AS400 Driver Not Capable. The operation could not be performed because the OLE DB Provider MSDASQL was unable to begin a distributed transaction.
What I don't understand is that it runs fine in SQL Query Analyser???
Should I be using something other than OPENQUERY to retrieve my information from the AS400?
Any ideas?
How would you do this?